diff --git a/DocGen4.lean b/DocGen4.lean
index e91e7c7..0ae1c74 100644
--- a/DocGen4.lean
+++ b/DocGen4.lean
@@ -3,10 +3,7 @@ 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 DocGen4.Hierarchy
import DocGen4.Process
import DocGen4.Load
-import DocGen4.ToHtmlFormat
import DocGen4.IncludeStr
import DocGen4.Output
-import DocGen4.Attributes
diff --git a/DocGen4/IncludeStr.lean b/DocGen4/IncludeStr.lean
index afc3ceb..d9ac0f9 100644
--- a/DocGen4/IncludeStr.lean
+++ b/DocGen4/IncludeStr.lean
@@ -27,6 +27,11 @@ partial def traverseDir (f : FilePath) (p : FilePath → IO Bool) : IO (Option F
syntax (name := includeStr) "include_str" str : term
+/--
+Provides a way to include the contents of a file at compile time as a String.
+This is used to include things like the CSS and JS in the binary so we
+don't have to carry them around as files.
+-/
@[termElab includeStr] def includeStrImpl : TermElab := λ stx expectedType? => do
let str := stx[1].isStrLit?.get!
let srcPath := (FilePath.mk (← read).fileName)
diff --git a/DocGen4/Load.lean b/DocGen4/Load.lean
index 841891a..09d2d5c 100644
--- a/DocGen4/Load.lean
+++ b/DocGen4/Load.lean
@@ -13,6 +13,11 @@ namespace DocGen4
open Lean System Std IO
+/--
+Sets up a lake workspace for the current project. Furthermore initialize
+the Lean search path with the path to the proper compiler from lean-toolchain
+as well as all the dependencies.
+-/
def lakeSetup (imports : List String) : IO (Except UInt32 (Lake.Workspace × String)) := do
let (leanInstall?, lakeInstall?) ← Lake.findInstall?
let res ← StateT.run Lake.Cli.loadWorkspace {leanInstall?, lakeInstall?} |>.toIO'
@@ -28,10 +33,14 @@ def lakeSetup (imports : List String) : IO (Except UInt32 (Lake.Workspace × Str
pure $ Except.ok (ws, lean.githash)
| Except.error rc => pure $ Except.error rc
-def load (imports : List Name) : IO AnalyzerResult := do
+/--
+Load a list of modules from the current Lean search path into an `Environment`
+to process for documentation.
+-/
+def load (imports : List Name) : IO Process.AnalyzerResult := do
let env ← importModules (List.map (Import.mk · false) imports) Options.empty
-- TODO parameterize maxHeartbeats
IO.println "Processing modules"
- Prod.fst <$> Meta.MetaM.toIO process { maxHeartbeats := 100000000, options := ⟨[(`pp.tagAppFns, true)]⟩ } { env := env} {} {}
+ Prod.fst <$> Meta.MetaM.toIO Process.process { maxHeartbeats := 100000000, options := ⟨[(`pp.tagAppFns, true)]⟩ } { env := env} {} {}
end DocGen4
diff --git a/DocGen4/Output.lean b/DocGen4/Output.lean
index 7919f67..59ad9e7 100644
--- a/DocGen4/Output.lean
+++ b/DocGen4/Output.lean
@@ -12,74 +12,16 @@ import DocGen4.Output.Module
import DocGen4.Output.NotFound
import DocGen4.Output.Find
import DocGen4.Output.Semantic
+import DocGen4.Output.SourceLinker
namespace DocGen4
-open Lean Std IO System Output
+open Lean IO System Output Process
-
-/-
-Three link types from git supported:
-- https://github.com/org/repo
-- https://github.com/org/repo.git
-- git@github.com:org/repo.git
-TODO: This function is quite brittle and very github specific, we can
-probably do better.
+/--
+The main entrypoint for outputting the documentation HTML based on an
+`AnalyzerResult`.
-/
-def getGithubBaseUrl (gitUrl : String) : String := Id.run do
- let mut url := gitUrl
- if url.startsWith "git@" then
- url := url.drop 15
- url := url.dropRight 4
- pure s!"https://github.com/{url}"
- else if url.endsWith ".git" then
- pure $ url.dropRight 4
- else
- pure url
-
-def getProjectGithubUrl : IO String := do
- let out ← IO.Process.output {cmd := "git", args := #["remote", "get-url", "origin"]}
- if out.exitCode != 0 then
- throw <| IO.userError <| "git exited with code " ++ toString out.exitCode
- pure out.stdout.trimRight
-
-def getProjectCommit : IO String := do
- let out ← IO.Process.output {cmd := "git", args := #["rev-parse", "HEAD"]}
- if out.exitCode != 0 then
- throw <| IO.userError <| "git exited with code " ++ toString out.exitCode
- pure out.stdout.trimRight
-
-def sourceLinker (ws : Lake.Workspace) (leanHash : String): IO (Name → Option DeclarationRange → String) := do
- -- Compute a map from package names to source URL
- let mut gitMap := Std.mkHashMap
- let projectBaseUrl := getGithubBaseUrl (←getProjectGithubUrl)
- let projectCommit ← getProjectCommit
- gitMap := gitMap.insert ws.root.name (projectBaseUrl, projectCommit)
- for pkg in ws.packageArray do
- for dep in pkg.dependencies do
- let value := match dep.src with
- | Lake.Source.git url commit => (getGithubBaseUrl url, commit)
- -- TODO: What do we do here if linking a source is not possible?
- | _ => ("https://example.com", "master")
- gitMap := gitMap.insert dep.name value
-
- pure $ λ module range =>
- let parts := module.components.map Name.toString
- let path := (parts.intersperse "/").foldl (· ++ ·) ""
- let root := module.getRoot
- let basic := if root == `Lean ∨ root == `Init ∨ root == `Std then
- s!"https://github.com/leanprover/lean4/blob/{leanHash}/src/{path}.lean"
- else
- match ws.packageForModule? module with
- | some pkg =>
- let (baseUrl, commit) := gitMap.find! pkg.name
- s!"{baseUrl}/blob/{commit}/{path}.lean"
- | none => "https://example.com"
-
- match range with
- | some range => s!"{basic}#L{range.pos.line}-L{range.endPos.line}"
- | none => basic
-
def htmlOutput (result : AnalyzerResult) (ws : Lake.Workspace) (leanHash: String) : IO Unit := do
let config : SiteContext := { depthToRoot := 0, result := result, currentName := none, sourceLinker := ←sourceLinker ws leanHash}
let basePath := FilePath.mk "." / "build" / "doc"
diff --git a/DocGen4/Output/Base.lean b/DocGen4/Output/Base.lean
index 4aef3b9..795daa8 100644
--- a/DocGen4/Output/Base.lean
+++ b/DocGen4/Output/Base.lean
@@ -5,18 +5,33 @@ Authors: Henrik Böving
-/
import DocGen4.Process
import DocGen4.IncludeStr
-import DocGen4.ToHtmlFormat
+import DocGen4.Output.ToHtmlFormat
-namespace DocGen4
-namespace Output
+namespace DocGen4.Output
open scoped DocGen4.Jsx
-open Lean System Widget Elab
+open Lean System Widget Elab Process
+/--
+The context used in the `HtmlM` monad for HTML templating.
+-/
structure SiteContext where
+ /--
+ The full analysis result from the Process module.
+ -/
result : AnalyzerResult
+ /--
+ How far away we are from the page root, used for relative links to the root.
+ -/
depthToRoot: Nat
+ /--
+ The name of the current module if there is one, there exist a few
+ pages that don't have a module name.
+ -/
currentName : Option Name
+ /--
+ A function to link declaration names to their source URLs, usually Github ones.
+ -/
sourceLinker : Name → Option DeclarationRange → String
def setCurrentName (name : Name) (ctx : SiteContext) := {ctx with currentName := some name}
@@ -24,6 +39,9 @@ def setCurrentName (name : Name) (ctx : SiteContext) := {ctx with currentName :=
abbrev HtmlT := ReaderT SiteContext
abbrev HtmlM := HtmlT Id
+/--
+Obtains the root URL as a relative one to the current depth.
+-/
def getRoot : HtmlM String := do
let rec go: Nat -> String
| 0 => "./"
@@ -35,22 +53,46 @@ def getResult : HtmlM AnalyzerResult := do pure (←read).result
def getCurrentName : HtmlM (Option Name) := do pure (←read).currentName
def getSourceUrl (module : Name) (range : Option DeclarationRange): HtmlM String := do pure $ (←read).sourceLinker module range
+/--
+If a template is meant to be extended because it for example only provides the
+header but no real content this is the way to fill the template with content.
+-/
def templateExtends {α β : Type} (base : α → HtmlM β) (new : HtmlM α) : HtmlM β :=
new >>= base
+/--
+Returns the doc-gen4 link to a module name.
+-/
def moduleNameToLink (n : Name) : HtmlM String := do
let parts := n.components.map Name.toString
pure $ (← getRoot) ++ (parts.intersperse "/").foldl (· ++ ·) "" ++ ".html"
+/--
+Returns the HTML doc-gen4 link to a module name.
+-/
+def moduleToHtmlLink (module : Name) : HtmlM Html := do
+ pure {module.toString}
+
+/--
+Returns the path to the HTML file that contains information about a module.
+-/
def moduleNameToFile (basePath : FilePath) (n : Name) : FilePath :=
let parts := n.components.map Name.toString
FilePath.withExtension (basePath / parts.foldl (· / ·) (FilePath.mk ".")) "html"
+/--
+Returns the directory of the HTML file that contains information about a module.
+-/
def moduleNameToDirectory (basePath : FilePath) (n : Name) : FilePath :=
let parts := n.components.dropLast.map Name.toString
basePath / parts.foldl (· / ·) (FilePath.mk ".")
+
section Static
+/-!
+The following section contains all the statically included files that
+are used in documentation generation, notably JS and CSS ones.
+-/
def styleCss : String := include_str "../../static/style.css"
def declarationDataCenterJs : String := include_str "../../static/declaration-data.js"
def navJs : String := include_str "../../static/nav.js"
@@ -60,11 +102,41 @@ section Static
def mathjaxConfigJs : String := include_str "../../static/mathjax-config.js"
end Static
+/--
+Returns the doc-gen4 link to a declaration name.
+-/
def declNameToLink (name : Name) : HtmlM String := do
let res ← getResult
let module := res.moduleNames[res.name2ModIdx.find! name]
pure $ (←moduleNameToLink module) ++ "#" ++ name.toString
+/--
+Returns the HTML doc-gen4 link to a declaration name.
+-/
+def declNameToHtmlLink (name : Name) : HtmlM Html := do
+ let link ← declNameToLink name
+ pure {name.toString}
+
+/--
+Returns the HTML doc-gen4 link to a declaration name with "break_within"
+set as class.
+-/
+def declNameToHtmlBreakWithinLink (name : Name) : HtmlM Html := do
+ let link ← declNameToLink name
+ pure {name.toString}
+
+/--
+In Lean syntax declarations the following pattern is quite common:
+```
+syntax term " + " term : term
+```
+that is, we place spaces around the operator in the middle. When the
+`InfoTree` framework provides us with information about what source token
+corresponds to which identifier it will thus say that `" + "` corresponds to
+`HAdd.hadd`. This is however not the way we want this to be linked, in the HTML
+only `+` should be linked, taking care of this is what this function is
+responsible for.
+-/
def splitWhitespaces (s : String) : (String × String × String) := Id.run do
let front := "".pushn ' ' $ s.offsetOfPos (s.find (!Char.isWhitespace ·))
let mut s := s.trimLeft
@@ -72,6 +144,11 @@ def splitWhitespaces (s : String) : (String × String × String) := Id.run do
s := s.trimRight
(front, s, back)
+/--
+Turns a `CodeWithInfos` object, that is basically a Lean syntax tree with
+information about what the identifiers mean, into an HTML object that links
+to as much information as possible.
+-/
partial def infoFormatToHtml (i : CodeWithInfos) : HtmlM (Array Html) := do
match i with
| TaggedText.text t => pure #[Html.escape t]
@@ -93,5 +170,4 @@ partial def infoFormatToHtml (i : CodeWithInfos) : HtmlM (Array Html) := do
pure #[Html.element "span" true #[("class", "fn")] (←infoFormatToHtml t)]
| _ => pure #[Html.element "span" true #[("class", "fn")] (←infoFormatToHtml t)]
-end Output
-end DocGen4
+end DocGen4.Output
diff --git a/DocGen4/Output/Class.lean b/DocGen4/Output/Class.lean
index 00fd252..5ca853e 100644
--- a/DocGen4/Output/Class.lean
+++ b/DocGen4/Output/Class.lean
@@ -1,5 +1,6 @@
import DocGen4.Output.Template
import DocGen4.Output.Structure
+import DocGen4.Process
namespace DocGen4
namespace Output
@@ -8,7 +9,7 @@ open scoped DocGen4.Jsx
open Lean
def classInstanceToHtml (name : Name) : HtmlM Html := do
- pure
def classInstancesToHtml (instances : Array Name) : HtmlM Html := do
let instancesHtml ← instances.mapM classInstanceToHtml
@@ -20,7 +21,7 @@ def classInstancesToHtml (instances : Array Name) : HtmlM Html := do
-def classToHtml (i : ClassInfo) : HtmlM (Array Html) := do
+def classToHtml (i : Process.ClassInfo) : HtmlM (Array Html) := do
pure $ (←structureToHtml i.toStructureInfo)
end Output
diff --git a/DocGen4/Output/ClassInductive.lean b/DocGen4/Output/ClassInductive.lean
index 140651e..7b8ab24 100644
--- a/DocGen4/Output/ClassInductive.lean
+++ b/DocGen4/Output/ClassInductive.lean
@@ -1,12 +1,13 @@
import DocGen4.Output.Template
import DocGen4.Output.Class
import DocGen4.Output.Inductive
+import DocGen4.Process
namespace DocGen4
namespace Output
-def classInductiveToHtml (i : ClassInductiveInfo) : HtmlM (Array Html) := do
+def classInductiveToHtml (i : Process.ClassInductiveInfo) : HtmlM (Array Html) := do
pure $ (←inductiveToHtml i.toInductiveInfo)
end Output
diff --git a/DocGen4/Output/Definition.lean b/DocGen4/Output/Definition.lean
index 3e0b146..4b4e280 100644
--- a/DocGen4/Output/Definition.lean
+++ b/DocGen4/Output/Definition.lean
@@ -1,5 +1,6 @@
import DocGen4.Output.Template
import DocGen4.Output.DocString
+import DocGen4.Process
namespace DocGen4
namespace Output
@@ -7,13 +8,19 @@ namespace Output
open scoped DocGen4.Jsx
open Lean Widget
-/- This is basically an arbitrary number that seems to work okay. -/
+/-- This is basically an arbitrary number that seems to work okay. -/
def equationLimit : Nat := 200
def equationToHtml (c : CodeWithInfos) : HtmlM Html := do
pure
[←infoFormatToHtml c]
-def equationsToHtml (i : DefinitionInfo) : HtmlM (Array Html) := do
+/--
+Attempt to render all `simp` equations for this definition. At a size
+defined in `equationLimit` we stop trying since they:
+- are too ugly to read most of the time
+- take too long
+-/
+def equationsToHtml (i : Process.DefinitionInfo) : HtmlM (Array Html) := do
if let some eqs := i.equations then
let equationsHtml ← eqs.mapM equationToHtml
let filteredEquationsHtml := equationsHtml.filter (λ eq => eq.textLength < equationLimit)
diff --git a/DocGen4/Output/DocString.lean b/DocGen4/Output/DocString.lean
index d729d38..d1506ab 100644
--- a/DocGen4/Output/DocString.lean
+++ b/DocGen4/Output/DocString.lean
@@ -3,7 +3,7 @@ import DocGen4.Output.Template
import Lean.Data.Parsec
import Unicode.General.GeneralCategory
-open Lean Unicode Xml Parser Parsec
+open Lean Unicode Xml Parser Parsec DocGen4.Process
namespace DocGen4
namespace Output
diff --git a/DocGen4/Output/Index.lean b/DocGen4/Output/Index.lean
index e0342b6..d31ea3d 100644
--- a/DocGen4/Output/Index.lean
+++ b/DocGen4/Output/Index.lean
@@ -3,7 +3,7 @@ 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 DocGen4.ToHtmlFormat
+import DocGen4.Output.ToHtmlFormat
import DocGen4.Output.Template
namespace DocGen4
diff --git a/DocGen4/Output/Inductive.lean b/DocGen4/Output/Inductive.lean
index 419891d..4a73bd3 100644
--- a/DocGen4/Output/Inductive.lean
+++ b/DocGen4/Output/Inductive.lean
@@ -1,17 +1,18 @@
import DocGen4.Output.Template
import DocGen4.Output.DocString
+import DocGen4.Process
namespace DocGen4
namespace Output
open scoped DocGen4.Jsx
-def ctorToHtml (i : NameInfo) : HtmlM Html := do
+def ctorToHtml (i : Process.NameInfo) : HtmlM Html := do
let shortName := i.name.components'.head!.toString
let name := i.name.toString
pure
{shortName} : [←infoFormatToHtml i.type]
-def inductiveToHtml (i : InductiveInfo) : HtmlM (Array Html) := do
+def inductiveToHtml (i : Process.InductiveInfo) : HtmlM (Array Html) := do
let constructorsHtml :=
[← i.ctors.toArray.mapM ctorToHtml]
pure #[constructorsHtml]
diff --git a/DocGen4/Output/Module.lean b/DocGen4/Output/Module.lean
index 062a3ca..d1ea32b 100644
--- a/DocGen4/Output/Module.lean
+++ b/DocGen4/Output/Module.lean
@@ -11,14 +11,19 @@ import DocGen4.Output.Definition
import DocGen4.Output.Instance
import DocGen4.Output.ClassInductive
import DocGen4.Output.DocString
+import DocGen4.Process
import Lean.Data.Xml.Parser
namespace DocGen4
namespace Output
open scoped DocGen4.Jsx
-open Lean
+open Lean Process
+/--
+Render an `Arg` as HTML, adding opacity effects etc. depending on what
+type of binder it has.
+-/
def argToHtml (arg : Arg) : HtmlM Html := do
let (l, r, implicit) := match arg.binderInfo with
| BinderInfo.default => ("(", ")", false)
@@ -37,19 +42,27 @@ def argToHtml (arg : Arg) : HtmlM Html := do
else
pure html
-def structureInfoHeader (s : StructureInfo) : HtmlM (Array Html) := do
+/--
+Render the structures this structure extends from as HTML so it can be
+added to the top level.
+-/
+def structureInfoHeader (s : Process.StructureInfo) : HtmlM (Array Html) := do
let mut nodes := #[]
if s.parents.size > 0 then
nodes := nodes.push extends
let mut parents := #[]
for parent in s.parents do
- let link := {parent.toString}
+ let link ← declNameToHtmlBreakWithinLink parent
let inner := Html.element "span" true #[("class", "fn")] #[link]
let html:= Html.element "span" false #[("class", "decl_parent")] #[inner]
parents := parents.push html
nodes := nodes.append (parents.toList.intersperse (Html.text ", ")).toArray
pure nodes
+/--
+Render the general header of a declaration containing its declaration type
+and name.
+-/
def docInfoHeader (doc : DocInfo) : HtmlM Html := do
let mut nodes := #[]
nodes := nodes.push {doc.getKindDescription}
@@ -63,7 +76,6 @@ def docInfoHeader (doc : DocInfo) : HtmlM Html := do
for arg in doc.getArgs do
nodes := nodes.push (←argToHtml arg)
- -- TODO: dedup this
match doc with
| DocInfo.structureInfo i => nodes := nodes.append (←structureInfoHeader i)
| DocInfo.classInfo i => nodes := nodes.append (←structureInfoHeader i.toStructureInfo)
@@ -73,6 +85,9 @@ def docInfoHeader (doc : DocInfo) : HtmlM Html := do
nodes := nodes.push $ Html.element "div" true #[("class", "decl_type")] (←infoFormatToHtml doc.getType)
pure
[nodes]
+/--
+The main entry point for rendering a single declaration inside a given module.
+-/
def docInfoToHtml (module : Name) (doc : DocInfo) : HtmlM Html := do
-- basic info like headers, types, structure fields, etc.
let docInfoHtml ← match doc with
@@ -114,12 +129,20 @@ def docInfoToHtml (module : Name) (doc : DocInfo) : HtmlM Html := do
+/--
+Rendering a module doc string, that is the ones with an ! after the opener
+as HTML.
+-/
def modDocToHtml (module : Name) (mdoc : ModuleDoc) : HtmlM Html := do
pure
[←docStringToHtml mdoc.doc]
+/--
+Render a module member, that is either a module doc string or a declaration
+as HTML.
+-/
def moduleMemberToHtml (module : Name) (member : ModuleMember) : HtmlM Html := do
match member with
| ModuleMember.docInfo d => docInfoToHtml module d
@@ -130,10 +153,9 @@ def declarationToNavLink (module : Name) : Html :=
{module.toString}
--- TODO: Similar functions are used all over the place, we should dedup them
-def moduleToNavLink (module : Name) : HtmlM Html := do
- pure {module.toString}
-
+/--
+Returns the list of all imports this module does.
+-/
def getImports (module : Name) : HtmlM (Array Name) := do
let res ← getResult
let some idx := res.moduleNames.findIdx? (. == module) | unreachable!
@@ -144,6 +166,17 @@ def getImports (module : Name) : HtmlM (Array Name) := do
imports := imports.push (res.moduleNames.get! i)
pure imports
+/--
+Sort the list of all modules this one is importing, linkify it
+and return the HTML.
+-/
+def importsHtml (moduleName : Name) : HtmlM (Array Html) := do
+ let imports := (←getImports moduleName) |>.qsort Name.lt
+ imports.mapM (λ i => do pure
{←moduleToHtmlLink i}
)
+
+/--
+Returns a list of all modules this module is imported by.
+-/
def getImportedBy (module : Name) : HtmlM (Array Name) := do
let res ← getResult
let some idx := res.moduleNames.findIdx? (. == module) | unreachable!
@@ -154,15 +187,17 @@ def getImportedBy (module : Name) : HtmlM (Array Name) := do
impBy := impBy.push (res.moduleNames.get! i)
pure impBy
+/--
+Sort the list of all modules this one is imported by, linkify it
+and return the HTML.
+-/
def importedByHtml (moduleName : Name) : HtmlM (Array Html) := do
let imports := (←getImportedBy moduleName) |>.qsort Name.lt
- imports.mapM (λ i => do pure
{←moduleToNavLink i}
)
-
-
-def importsHtml (moduleName : Name) : HtmlM (Array Html) := do
- let imports := (←getImports moduleName) |>.qsort Name.lt
- imports.mapM (λ i => do pure
{←moduleToNavLink i}
)
+ imports.mapM (λ i => do pure
{←moduleToHtmlLink i}
)
+/--
+Render the internal nav bar (the thing on the right on all module pages).
+-/
def internalNav (members : Array Name) (moduleName : Name) : HtmlM Html := do
pure
-def moduleToHtml (module : Module) : HtmlM Html := withReader (setCurrentName module.name) do
+/--
+The main entry point to rendering the HTML for an entire module.
+-/
+def moduleToHtml (module : Process.Module) : HtmlM Html := withReader (setCurrentName module.name) do
let memberDocs ← module.members.mapM (λ i => moduleMemberToHtml module.name i)
let memberNames := filterMapDocInfo module.members |>.map DocInfo.getName
- templateExtends (baseHtmlArray module.name.toString) $ pure #[
+ templateExtends (baseHtmlGenerator module.name.toString) $ pure #[
←internalNav memberNames module.name,
Html.element "main" false #[] memberDocs
]
diff --git a/DocGen4/Output/Navbar.lean b/DocGen4/Output/Navbar.lean
index 7d00102..bec70af 100644
--- a/DocGen4/Output/Navbar.lean
+++ b/DocGen4/Output/Navbar.lean
@@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Henrik Böving
-/
import Lean
-import DocGen4.ToHtmlFormat
+import DocGen4.Output.ToHtmlFormat
import DocGen4.Output.Base
namespace DocGen4
@@ -15,9 +15,12 @@ open scoped DocGen4.Jsx
def moduleListFile (file : Name) : HtmlM Html := do
pure
+/--
+Build the HTML tree representing the module hierarchy.
+-/
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)
@@ -31,7 +34,7 @@ partial def moduleListDir (h : Hierarchy) : HtmlM Html := do
[if (←getCurrentName).any (h.getName.isPrefixOf ·) then #[("open", "")] else #[]]>
{
if (←getResult).moduleInfo.contains h.getName then
- Html.element "summary" true #[] #[{h.getName.toString}]
+ Html.element "summary" true #[] #[←moduleToHtmlLink h.getName]
else
{h.getName.toString}
}
@@ -39,6 +42,9 @@ partial def moduleListDir (h : Hierarchy) : HtmlM Html := do
[fileNodes]
+/--
+Return a list of top level modules, linkified and rendered as HTML
+-/
def moduleList : HtmlM Html := do
let hierarchy := (←getResult).hierarchy
let mut list := Array.empty
@@ -46,6 +52,9 @@ def moduleList : HtmlM Html := do
list := list.push $ ←moduleListDir cs
pure
[list]
+/--
+The main entry point to rendering the navbar on the left hand side.
+-/
def navbar : HtmlM Html := do
pure