Keep alphabetical ordering and color PDF files.
parent
62d0cf38b2
commit
143b23cbab
|
@ -15,7 +15,7 @@ open scoped DocGen4.Jsx
|
|||
|
||||
def moduleListFile (file : NameExt) : BaseHtmlM Html := do
|
||||
return <div class={if (← getCurrentName) == file.name then "nav_link visible" else "nav_link"}>
|
||||
<a href={← moduleNameExtToLink file}>{file.getString!}</a>
|
||||
<a class={if file.ext == .pdf then "pdf_link" else ""} href={← moduleNameExtToLink file}>{file.getString!}</a>
|
||||
</div>
|
||||
|
||||
/--
|
||||
|
@ -23,11 +23,14 @@ Build the HTML tree representing the module hierarchy.
|
|||
-/
|
||||
partial def moduleListDir (h : Hierarchy) : BaseHtmlM Html := do
|
||||
let children := Array.mk (h.getChildren.toList.map Prod.snd)
|
||||
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)
|
||||
|>.map Hierarchy.getNameExt
|
||||
let dirNodes ← dirs.mapM moduleListDir
|
||||
let fileNodes ← files.mapM moduleListFile
|
||||
let nodes ← children.mapM (fun c =>
|
||||
if c.getChildren.toList.length != 0 then
|
||||
moduleListDir c
|
||||
else if Hierarchy.isFile c && c.getChildren.toList.length = 0 then
|
||||
moduleListFile (Hierarchy.getNameExt c)
|
||||
else
|
||||
pure ""
|
||||
)
|
||||
let moduleLink ← moduleNameToHtmlLink h.getName
|
||||
let summary :=
|
||||
if h.isFile then
|
||||
|
@ -38,8 +41,7 @@ partial def moduleListDir (h : Hierarchy) : BaseHtmlM Html := do
|
|||
pure
|
||||
<details class="nav_sect" "data-path"={moduleLink} [if (← getCurrentName).any (h.getName.isPrefixOf ·) then #[("open", "")] else #[]]>
|
||||
{summary}
|
||||
[dirNodes]
|
||||
[fileNodes]
|
||||
[nodes]
|
||||
</details>
|
||||
|
||||
/--
|
||||
|
|
|
@ -18,6 +18,12 @@ def cmp : Extension → Extension → Ordering
|
|||
| pdf, pdf => Ordering.eq
|
||||
| pdf, _ => Ordering.gt
|
||||
|
||||
instance : BEq Extension where
|
||||
beq e1 e2 :=
|
||||
match cmp e1 e2 with
|
||||
| Ordering.eq => true
|
||||
| _ => false
|
||||
|
||||
def toString : Extension → String
|
||||
| html => "html"
|
||||
| pdf => "pdf"
|
||||
|
|
|
@ -14,6 +14,10 @@ a {
|
|||
color: var(--link-color);
|
||||
}
|
||||
|
||||
a.pdf_link {
|
||||
color: purple;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: 'Merriweather', serif;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue