bookshelf-doc/DocGen4/Output/Definition.lean

39 lines
961 B
Plaintext
Raw Normal View History

2022-02-15 11:27:12 +00:00
import CMark
import DocGen4.Output.Template
namespace DocGen4
namespace Output
open scoped DocGen4.Jsx
open Lean Widget
def equationToHtml (c : CodeWithInfos) : HtmlM Html := do
2022-02-12 14:09:13 +00:00
pure <li «class»="equation">[←infoFormatToHtml c]</li>
def equationsToHtml (i : DefinitionInfo) : HtmlM (Option Html) := do
2022-02-12 14:09:13 +00:00
if let some eqs := i.equations then
let equationsHtml ← eqs.mapM equationToHtml
2022-02-12 14:09:13 +00:00
pure
<details>
<summary>Equations</summary>
<ul «class»="equations">
[equationsHtml]
</ul>
</details>
else
2022-02-12 14:09:13 +00:00
pure none
def definitionToHtml (i : DefinitionInfo) : HtmlM (Array Html) := do
2022-02-15 11:27:12 +00:00
let equationsHtml? ← equationsToHtml i
let docstringHtml? := i.doc.map λ s => Html.text (CMark.renderHtml s)
match equationsHtml?, docstringHtml? with
| some e, some d => pure #[e, d]
| some e, none => pure #[e]
| none , some e => pure #[e]
| none , none => pure #[]
end Output
end DocGen4