/- 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 import Std.Data.HashMap import DocGen4.Process import DocGen4.ToHtmlFormat import DocGen4.IncludeStr namespace DocGen4 open Lean Std open scoped DocGen4.Jsx structure SiteContext where root : String result : AnalyzerResult abbrev HtmlM := Reader SiteContext def getRoot : HtmlM String := do (←read).root def getResult : HtmlM AnalyzerResult := do (←read).result def templateExtends {α β : Type} (base : α → HtmlM β) (new : HtmlM α) : HtmlM β := new >>= base def nameToPath (n : Name) : String := do let parts := n.components.map Name.toString return (parts.intersperse "/").foldl (· ++ ·) "" ++ ".html" partial def moduleListAux (h : Hierarchy) : HtmlM Html := do if h.getChildren.toList.length == 0 then
else let children := Array.mk (h.getChildren.toList.map Prod.snd) -- TODO: Is having no children really the correct criterium for a clickable module? let (dirs, files) := children.partition (λ c => c.getChildren.toList.length != 0) let nodes := (←(dirs.mapM moduleListAux)) ++ (←(files.mapM moduleListAux)) return{title}
-- TODO: Replace this form with our own search