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-02-12 14:09:13 +00:00
|
|
|
def moduleListFile (file : Name) : HtmlM Html := do
|
2022-05-19 09:14:47 +00:00
|
|
|
pure <div class={if (← getCurrentName) == file then "nav_link visible" else "nav_link"}>
|
2022-01-20 13:51:24 +00:00
|
|
|
<a href={← moduleNameToLink file}>{file.toString}</a>
|
|
|
|
</div>
|
2021-12-15 08:24:49 +00:00
|
|
|
|
|
|
|
partial def moduleListDir (h : Hierarchy) : HtmlM Html := do
|
|
|
|
let children := Array.mk (h.getChildren.toList.map Prod.snd)
|
|
|
|
let dirs := children.filter (λ c => c.getChildren.toList.length != 0)
|
2022-02-18 17:54:20 +00:00
|
|
|
let files := children.filter (λ c => Hierarchy.isFile c ∧ c.getChildren.toList.length = 0)
|
|
|
|
|>.map Hierarchy.getName
|
2021-12-15 08:24:49 +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-02-12 14:09:13 +00:00
|
|
|
pure
|
2022-05-19 15:16:40 +00:00
|
|
|
<details class="nav_sect" "data-path"={moduleLink}
|
2022-02-12 14:09:13 +00:00
|
|
|
[if (←getCurrentName).any (h.getName.isPrefixOf ·) then #[("open", "")] else #[]]>
|
2022-02-23 15:33:34 +00:00
|
|
|
{
|
|
|
|
if (←getResult).moduleInfo.contains h.getName then
|
|
|
|
Html.element "summary" true #[] #[<a "href"={← moduleNameToLink h.getName}>{h.getName.toString}</a>]
|
|
|
|
else
|
|
|
|
<summary>{h.getName.toString}</summary>
|
|
|
|
}
|
2022-02-12 14:09:13 +00:00
|
|
|
[dirNodes]
|
|
|
|
[fileNodes]
|
|
|
|
</details>
|
2021-12-15 08:24:49 +00:00
|
|
|
|
2022-01-20 14:01:51 +00:00
|
|
|
def moduleList : HtmlM Html := do
|
2021-12-15 08:24:49 +00:00
|
|
|
let hierarchy := (←getResult).hierarchy
|
|
|
|
let mut list := Array.empty
|
|
|
|
for (n, cs) in hierarchy.getChildren do
|
|
|
|
list := list.push $ ←moduleListDir cs
|
2022-05-19 15:16:40 +00:00
|
|
|
pure <div class="module_list">[list]</div>
|
2021-12-15 08:24:49 +00:00
|
|
|
|
|
|
|
def navbar : HtmlM Html := do
|
2022-02-12 14:09:13 +00:00
|
|
|
pure
|
2022-05-19 09:14:47 +00:00
|
|
|
<nav class="nav">
|
2022-02-12 14:09:13 +00:00
|
|
|
<h3>General documentation</h3>
|
2022-05-19 09:14:47 +00:00
|
|
|
<div class="nav_link"><a href={s!"{←getRoot}"}>index</a></div>
|
2022-02-12 14:09:13 +00:00
|
|
|
/-
|
|
|
|
TODO: Add these in later
|
2022-05-19 09:14:47 +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-02-12 14:09:13 +00:00
|
|
|
-/
|
|
|
|
<h3>Library</h3>
|
|
|
|
{← moduleList}
|
|
|
|
</nav>
|
2021-12-15 08:24:49 +00:00
|
|
|
|
|
|
|
end Output
|
|
|
|
end DocGen4
|