import DocGen4.Output.Template
import DocGen4.Output.DocString
import DocGen4.Process
namespace DocGen4
namespace Output
open scoped DocGen4.Jsx
open Lean
/--
Render a single field consisting of its documentation, its name and its type as HTML.
-/
def fieldToHtml (f : Process.NameInfo) : HtmlM Html := do
let shortName := f.name.componentsRev.head!.toString
let name := f.name.toString
if let some doc := f.doc then
let renderedDoc ← docStringToHtml doc
pure
{s!"{shortName} "} : [← infoFormatToHtml f.type]
[renderedDoc]
else
pure
{s!"{shortName} "} : [← infoFormatToHtml f.type]
/--
Render all information about a structure as HTML.
-/
def structureToHtml (i : Process.StructureInfo) : HtmlM (Array Html) := do
let structureHtml :=
if Name.isSuffixOf `mk i.ctor.name then
(
[← i.fieldInfo.mapM fieldToHtml]
)
else
let ctorShortName := i.ctor.name.componentsRev.head!.toString
(
- {s!"{ctorShortName} "} :: (
[← i.fieldInfo.mapM fieldToHtml]
- )
)
return #[structureHtml]
end Output
end DocGen4