2022-01-04 07:23:39 +00:00
|
|
|
import DocGen4.Output.Template
|
2022-02-17 05:47:38 +00:00
|
|
|
import DocGen4.Output.DocString
|
2022-01-04 07:23:39 +00:00
|
|
|
|
|
|
|
namespace DocGen4
|
|
|
|
namespace Output
|
|
|
|
|
|
|
|
open scoped DocGen4.Jsx
|
2022-02-02 11:53:04 +00:00
|
|
|
open Lean
|
2022-01-04 07:23:39 +00:00
|
|
|
|
|
|
|
def fieldToHtml (f : NameInfo) : HtmlM Html := do
|
2022-01-09 13:07:50 +00:00
|
|
|
let shortName := f.name.components'.head!.toString
|
|
|
|
let name := f.name.toString
|
2022-02-12 14:09:13 +00:00
|
|
|
pure <li «class»="structure_field" id={name}>{s!"{shortName} "} : [←infoFormatToHtml f.type]</li>
|
2022-01-04 07:23:39 +00:00
|
|
|
|
|
|
|
def structureToHtml (i : StructureInfo) : HtmlM (Array Html) := do
|
2022-02-15 11:27:12 +00:00
|
|
|
let structureHtml :=
|
|
|
|
if Name.isSuffixOf `mk i.ctor.name then
|
|
|
|
(<ul «class»="structure_fields" id={i.ctor.name.toString}>
|
2022-02-12 14:09:13 +00:00
|
|
|
[←i.fieldInfo.mapM fieldToHtml]
|
2022-02-15 11:27:12 +00:00
|
|
|
</ul>)
|
|
|
|
else
|
|
|
|
let ctorShortName := i.ctor.name.components'.head!.toString
|
|
|
|
(<ul «class»="structure_ext">
|
2022-02-02 11:53:04 +00:00
|
|
|
<li id={i.ctor.name.toString} «class»="structure_ext_ctor">{s!"{ctorShortName} "} :: (</li>
|
|
|
|
<ul «class»="structure_ext_fields">
|
|
|
|
[←i.fieldInfo.mapM fieldToHtml]
|
|
|
|
</ul>
|
|
|
|
<li «class»="structure_ext_ctor">)</li>
|
2022-02-15 11:27:12 +00:00
|
|
|
</ul>)
|
2022-02-17 05:47:38 +00:00
|
|
|
let docstringHtml? := i.doc.map docStringToHtml
|
2022-02-15 11:27:12 +00:00
|
|
|
match docstringHtml? with
|
|
|
|
| some d => pure #[structureHtml, d]
|
|
|
|
| none => pure #[structureHtml]
|
2022-01-04 07:23:39 +00:00
|
|
|
|
|
|
|
end Output
|
|
|
|
end DocGen4
|