2022-02-02 10:22:15 +00:00
|
|
|
import DocGen4.Output.Template
|
2022-02-17 05:47:38 +00:00
|
|
|
import DocGen4.Output.DocString
|
2022-02-02 10:22:15 +00:00
|
|
|
|
|
|
|
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>
|
2022-02-02 10:22:15 +00:00
|
|
|
|
|
|
|
def equationsToHtml (i : DefinitionInfo) : HtmlM (Option Html) := do
|
2022-02-12 14:09:13 +00:00
|
|
|
if let some eqs := i.equations then
|
2022-02-02 10:22:15 +00:00
|
|
|
let equationsHtml ← eqs.mapM equationToHtml
|
2022-02-12 14:09:13 +00:00
|
|
|
pure
|
|
|
|
<details>
|
|
|
|
<summary>Equations</summary>
|
|
|
|
<ul «class»="equations">
|
|
|
|
[equationsHtml]
|
|
|
|
</ul>
|
|
|
|
</details>
|
2022-02-02 10:22:15 +00:00
|
|
|
else
|
2022-02-12 14:09:13 +00:00
|
|
|
pure none
|
2022-02-02 10:22:15 +00:00
|
|
|
|
|
|
|
def definitionToHtml (i : DefinitionInfo) : HtmlM (Array Html) := do
|
2022-02-15 11:27:12 +00:00
|
|
|
let equationsHtml? ← equationsToHtml i
|
2022-02-17 13:26:02 +00:00
|
|
|
let docstringHtml? ← i.doc.mapM docStringToHtml
|
2022-02-15 11:27:12 +00:00
|
|
|
match equationsHtml?, docstringHtml? with
|
2022-02-17 13:26:02 +00:00
|
|
|
| some e, some d => pure (#[e] ++ d)
|
2022-02-15 11:27:12 +00:00
|
|
|
| some e, none => pure #[e]
|
2022-02-17 13:26:02 +00:00
|
|
|
| none , some d => pure d
|
2022-02-15 11:27:12 +00:00
|
|
|
| none , none => pure #[]
|
|
|
|
|
2022-02-02 10:22:15 +00:00
|
|
|
|
|
|
|
end Output
|
|
|
|
end DocGen4
|
|
|
|
|