2021-12-15 08:24:49 +00:00
|
|
|
/-
|
|
|
|
Copyright (c) 2021 Henrik Böving. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Authors: Henrik Böving
|
|
|
|
-/
|
|
|
|
import Lean
|
2022-05-19 18:36:35 +00:00
|
|
|
import DocGen4.Output.ToHtmlFormat
|
2021-12-15 08:24:49 +00:00
|
|
|
import DocGen4.Output.Base
|
|
|
|
|
|
|
|
namespace DocGen4
|
|
|
|
namespace Output
|
|
|
|
|
|
|
|
open Lean
|
|
|
|
open scoped DocGen4.Jsx
|
|
|
|
|
2022-07-20 23:40:04 +00:00
|
|
|
def moduleListFile (file : Name) : BaseHtmlM Html := do
|
2023-01-01 18:51:01 +00:00
|
|
|
return <div class={if (← getCurrentName) == file then "nav_link visible" else "nav_link"}>
|
|
|
|
<a href={← moduleNameToLink file}>{file.getString!}</a>
|
2022-01-20 13:51:24 +00:00
|
|
|
</div>
|
2021-12-15 08:24:49 +00:00
|
|
|
|
2022-05-19 19:49:25 +00:00
|
|
|
/--
|
|
|
|
Build the HTML tree representing the module hierarchy.
|
|
|
|
-/
|
2022-07-20 23:40:04 +00:00
|
|
|
partial def moduleListDir (h : Hierarchy) : BaseHtmlM Html := do
|
2021-12-15 08:24:49 +00:00
|
|
|
let children := Array.mk (h.getChildren.toList.map Prod.snd)
|
2023-01-01 18:51:01 +00:00
|
|
|
let dirs := children.filter (fun c => c.getChildren.toList.length != 0)
|
|
|
|
let files := children.filter (fun c => Hierarchy.isFile c && c.getChildren.toList.length = 0)
|
2022-02-18 17:54:20 +00:00
|
|
|
|>.map Hierarchy.getName
|
2023-01-01 18:51:01 +00:00
|
|
|
let dirNodes ← dirs.mapM moduleListDir
|
|
|
|
let fileNodes ← files.mapM moduleListFile
|
2021-12-17 16:20:44 +00:00
|
|
|
let moduleLink ← moduleNameToLink h.getName
|
2022-06-21 18:54:29 +00:00
|
|
|
let summary :=
|
2022-07-20 23:40:04 +00:00
|
|
|
if h.isFile then
|
2023-01-01 19:00:42 +00:00
|
|
|
<summary>{s!"{h.getName.getString!} ({<a href={← moduleNameToLink h.getName}>file</a>})"} </summary>
|
2022-06-21 18:54:29 +00:00
|
|
|
else
|
2022-12-13 17:58:02 +00:00
|
|
|
<summary>{h.getName.getString!}</summary>
|
2022-06-21 18:54:29 +00:00
|
|
|
|
2022-02-12 14:09:13 +00:00
|
|
|
pure
|
2023-01-01 18:51:01 +00:00
|
|
|
<details class="nav_sect" "data-path"={moduleLink} [if (← getCurrentName).any (h.getName.isPrefixOf ·) then #[("open", "")] else #[]]>
|
2022-06-21 18:54:29 +00:00
|
|
|
{summary}
|
2022-02-12 14:09:13 +00:00
|
|
|
[dirNodes]
|
|
|
|
[fileNodes]
|
|
|
|
</details>
|
2021-12-15 08:24:49 +00:00
|
|
|
|
2022-05-19 19:49:25 +00:00
|
|
|
/--
|
|
|
|
Return a list of top level modules, linkified and rendered as HTML
|
|
|
|
-/
|
2022-07-20 23:40:04 +00:00
|
|
|
def moduleList : BaseHtmlM Html := do
|
|
|
|
let hierarchy ← getHierarchy
|
2021-12-15 08:24:49 +00:00
|
|
|
let mut list := Array.empty
|
2022-07-20 23:40:04 +00:00
|
|
|
for (_, cs) in hierarchy.getChildren do
|
2023-01-01 18:51:01 +00:00
|
|
|
list := list.push <| ← moduleListDir cs
|
|
|
|
return <div class="module_list">[list]</div>
|
2021-12-15 08:24:49 +00:00
|
|
|
|
2022-05-19 19:49:25 +00:00
|
|
|
/--
|
|
|
|
The main entry point to rendering the navbar on the left hand side.
|
|
|
|
-/
|
2022-07-20 23:40:04 +00:00
|
|
|
def navbar : BaseHtmlM Html := do
|
2022-02-12 14:09:13 +00:00
|
|
|
pure
|
2022-07-21 20:06:26 +00:00
|
|
|
<html lang="en">
|
2022-07-21 21:01:15 +00:00
|
|
|
<head>
|
2023-01-01 18:51:01 +00:00
|
|
|
[← baseHtmlHeadDeclarations]
|
2022-07-21 21:01:15 +00:00
|
|
|
|
2023-01-01 18:51:01 +00:00
|
|
|
<script type="module" src={s!"{← getRoot}nav.js"}></script>
|
2023-06-08 05:52:51 +00:00
|
|
|
<script type="module" src={s!"{← getRoot}color-scheme.js"}></script>
|
2022-07-21 21:01:15 +00:00
|
|
|
<base target="_parent" />
|
|
|
|
</head>
|
|
|
|
|
2022-07-21 20:06:26 +00:00
|
|
|
<body>
|
2022-07-22 15:18:09 +00:00
|
|
|
<div class="navframe">
|
2022-07-21 20:06:26 +00:00
|
|
|
<nav class="nav">
|
|
|
|
<h3>General documentation</h3>
|
2023-01-01 18:51:01 +00:00
|
|
|
<div class="nav_link"><a href={s!"{← getRoot}"}>index</a></div>
|
|
|
|
<div class="nav_link"><a href={s!"{← getRoot}foundational_types.html"}>foundational types</a></div>
|
2022-07-21 20:06:26 +00:00
|
|
|
/-
|
|
|
|
TODO: Add these in later
|
2023-01-01 18:51:01 +00:00
|
|
|
<div class="nav_link"><a href={s!"{← getRoot}tactics.html"}>tactics</a></div>
|
|
|
|
<div class="nav_link"><a href={s!"{← getRoot}commands.html"}>commands</a></div>
|
|
|
|
<div class="nav_link"><a href={s!"{← getRoot}hole_commands.html"}>hole commands</a></div>
|
|
|
|
<div class="nav_link"><a href={s!"{← getRoot}attributes.html"}>attributes</a></div>
|
|
|
|
<div class="nav_link"><a href={s!"{← getRoot}notes.html"}>notes</a></div>
|
|
|
|
<div class="nav_link"><a href={s!"{← getRoot}references.html"}>references</a></div>
|
2022-07-21 20:06:26 +00:00
|
|
|
-/
|
|
|
|
<h3>Library</h3>
|
|
|
|
{← moduleList}
|
2023-06-09 20:26:17 +00:00
|
|
|
<div id="settings" hidden="hidden">
|
2023-06-08 05:52:51 +00:00
|
|
|
-- `input` is a void tag, but can be self-closed to make parsing easier.
|
|
|
|
<h3>Color scheme</h3>
|
|
|
|
<form id="color-theme-switcher">
|
|
|
|
<label for="color-theme-dark">
|
|
|
|
<input type="radio" name="color_theme" id="color-theme-dark" value="dark" autocomplete="off"/>dark</label>
|
|
|
|
<label for="color-theme-system" title="Match system theme settings">
|
|
|
|
<input type="radio" name="color_theme" id="color-theme-system" value="system" autocomplete="off"/>system</label>
|
|
|
|
<label for="color-theme-light">
|
|
|
|
<input type="radio" name="color_theme" id="color-theme-light" value="light" autocomplete="off"/>light</label>
|
|
|
|
</form>
|
|
|
|
</div>
|
2022-07-21 20:06:26 +00:00
|
|
|
</nav>
|
2022-07-22 15:18:09 +00:00
|
|
|
</div>
|
2022-07-21 20:06:26 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
2021-12-15 08:24:49 +00:00
|
|
|
|
|
|
|
end Output
|
|
|
|
end DocGen4
|