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-05-19 22:36:43 +00:00
|
|
|
import DocGen4.Process
|
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
|
|
|
|
2022-05-19 19:52:54 +00:00
|
|
|
/--
|
|
|
|
Render a single field consisting of its documentation, its name and its type as HTML.
|
|
|
|
-/
|
2022-05-19 22:36:43 +00:00
|
|
|
def fieldToHtml (f : Process.NameInfo) : HtmlM Html := do
|
2022-10-20 17:51:26 +00:00
|
|
|
let shortName := f.name.componentsRev.head!.toString
|
2022-01-09 13:07:50 +00:00
|
|
|
let name := f.name.toString
|
2022-04-09 19:39:34 +00:00
|
|
|
if let some doc := f.doc then
|
|
|
|
let renderedDoc ← docStringToHtml doc
|
|
|
|
pure
|
2022-05-19 09:14:47 +00:00
|
|
|
<li id={name} class="structure_field">
|
|
|
|
<div class="structure_field_doc">[renderedDoc]</div>
|
2023-01-01 18:51:01 +00:00
|
|
|
<div class="structure_field_info">{s!"{shortName} "} : [← infoFormatToHtml f.type]</div>
|
2022-04-09 19:39:34 +00:00
|
|
|
</li>
|
|
|
|
else
|
|
|
|
pure
|
2022-05-19 09:14:47 +00:00
|
|
|
<li id={name} class="structure_field">
|
2023-01-01 18:51:01 +00:00
|
|
|
<div class="structure_field_info">{s!"{shortName} "} : [← infoFormatToHtml f.type]</div>
|
2022-04-09 19:39:34 +00:00
|
|
|
</li>
|
2022-01-04 07:23:39 +00:00
|
|
|
|
2022-05-19 19:52:54 +00:00
|
|
|
/--
|
|
|
|
Render all information about a structure as HTML.
|
|
|
|
-/
|
2022-05-19 22:36:43 +00:00
|
|
|
def structureToHtml (i : Process.StructureInfo) : HtmlM (Array Html) := do
|
2022-02-15 11:27:12 +00:00
|
|
|
let structureHtml :=
|
|
|
|
if Name.isSuffixOf `mk i.ctor.name then
|
2022-05-19 09:14:47 +00:00
|
|
|
(<ul class="structure_fields" id={i.ctor.name.toString}>
|
2023-01-01 18:51:01 +00:00
|
|
|
[← i.fieldInfo.mapM fieldToHtml]
|
2022-02-15 11:27:12 +00:00
|
|
|
</ul>)
|
|
|
|
else
|
2022-10-20 17:51:26 +00:00
|
|
|
let ctorShortName := i.ctor.name.componentsRev.head!.toString
|
2022-05-19 09:14:47 +00:00
|
|
|
(<ul class="structure_ext">
|
|
|
|
<li id={i.ctor.name.toString} class="structure_ext_ctor">{s!"{ctorShortName} "} :: (</li>
|
|
|
|
<ul class="structure_ext_fields">
|
2023-01-01 18:51:01 +00:00
|
|
|
[← i.fieldInfo.mapM fieldToHtml]
|
2022-02-02 11:53:04 +00:00
|
|
|
</ul>
|
2022-05-19 09:14:47 +00:00
|
|
|
<li class="structure_ext_ctor">)</li>
|
2022-02-15 11:27:12 +00:00
|
|
|
</ul>)
|
2023-01-01 18:51:01 +00:00
|
|
|
return #[structureHtml]
|
2022-01-04 07:23:39 +00:00
|
|
|
|
|
|
|
end Output
|
|
|
|
end DocGen4
|