feat: Inductive constructor doc strings

main
Henrik Böving 2022-07-21 20:23:27 +02:00
parent 55f0399ed3
commit 601b895e89
2 changed files with 20 additions and 4 deletions

View File

@ -7,10 +7,21 @@ namespace Output
open scoped DocGen4.Jsx open scoped DocGen4.Jsx
def ctorToHtml (i : Process.NameInfo) : HtmlM Html := do def ctorToHtml (c : Process.NameInfo) : HtmlM Html := do
let shortName := i.name.components'.head!.toString let shortName := c.name.components'.head!.toString
let name := i.name.toString let name := c.name.toString
pure <li class="constructor" id={name}>{shortName} : [←infoFormatToHtml i.type]</li> if let some doc := c.doc then
let renderedDoc ← docStringToHtml doc
pure
<li class="constructor" id={name}>
<div class="inductive_ctor_doc">[renderedDoc]</div>
{shortName} : [←infoFormatToHtml c.type]
</li>
else
pure
<li class="constructor" id={name}>
{shortName} : [←infoFormatToHtml c.type]
</li>
def inductiveToHtml (i : Process.InductiveInfo) : HtmlM (Array Html) := do def inductiveToHtml (i : Process.InductiveInfo) : HtmlM (Array Html) := do
let constructorsHtml := <ul class="constructors">[← i.ctors.toArray.mapM ctorToHtml]</ul> let constructorsHtml := <ul class="constructors">[← i.ctors.toArray.mapM ctorToHtml]</ul>

View File

@ -491,6 +491,11 @@ pre code { padding: 0 0; }
margin-left: 2ex; margin-left: 2ex;
} }
.inductive_ctor_doc {
text-indent: 2ex;
padding-top: 1ex;
}
.structure_field_doc { .structure_field_doc {
text-indent: 0; text-indent: 0;
padding-top: 1ex; padding-top: 1ex;