fix: fix docstring order

main
Xubai Wang 2022-02-18 11:28:44 +08:00
parent 0724806fe6
commit d8a5f52c10
4 changed files with 13 additions and 21 deletions

View File

@ -25,12 +25,9 @@ def equationsToHtml (i : DefinitionInfo) : HtmlM (Option Html) := do
def definitionToHtml (i : DefinitionInfo) : HtmlM (Array Html) := do
let equationsHtml? ← equationsToHtml i
let docstringHtml? ← i.doc.mapM docStringToHtml
match equationsHtml?, docstringHtml? with
| some e, some d => pure (#[e] ++ d)
| some e, none => pure #[e]
| none , some d => pure d
| none , none => pure #[]
match equationsHtml? with
| some e => pure #[e]
| none => pure #[]
end Output

View File

@ -13,10 +13,7 @@ def ctorToHtml (i : NameInfo) : HtmlM Html := do
def inductiveToHtml (i : InductiveInfo) : HtmlM (Array Html) := do
let constructorsHtml := <ul "class"="constructors">[← i.ctors.toArray.mapM ctorToHtml]</ul>
let docstringHtml? ← i.doc.mapM docStringToHtml
match docstringHtml? with
| some d => pure (#[constructorsHtml] ++ d)
| none => pure #[constructorsHtml]
pure #[constructorsHtml]
end Output
end DocGen4

View File

@ -74,17 +74,17 @@ def docInfoHeader (doc : DocInfo) : HtmlM Html := do
pure <div «class»="decl_header"> [nodes] </div>
def docInfoToHtml (module : Name) (doc : DocInfo) : HtmlM Html := do
let docHtml ← match doc with
let docInfoHtml ← match doc with
| DocInfo.inductiveInfo i => inductiveToHtml i
| DocInfo.structureInfo i => structureToHtml i
| DocInfo.classInfo i => classToHtml i
| DocInfo.definitionInfo i => definitionToHtml i
| DocInfo.instanceInfo i => instanceToHtml i
| DocInfo.classInductiveInfo i => classInductiveToHtml i
| i => match i.getDocString with
| some d => pure (← docStringToHtml d)
| _ => pure #[]
| i => pure #[]
let docStringHtml ← match doc.getDocString with
| some s => docStringToHtml s
| none => pure #[]
let attrs := doc.getAttrs
let attrsHtml :=
if attrs.size > 0 then
@ -101,7 +101,8 @@ def docInfoToHtml (module : Name) (doc : DocInfo) : HtmlM Html := do
</div>
[attrsHtml]
{←docInfoHeader doc}
[docHtml]
[docStringHtml]
[docInfoHtml]
</div>
</div>
@ -111,7 +112,7 @@ def modDocToHtml (module : Name) (mdoc : ModuleDoc) : HtmlM Html := do
[←docStringToHtml mdoc.doc]
</div>
def moduleMemberToHtml (module : Name) (member : ModuleMember) : HtmlM Html :=
def moduleMemberToHtml (module : Name) (member : ModuleMember) : HtmlM Html := do
match member with
| ModuleMember.docInfo d => docInfoToHtml module d
| ModuleMember.modDoc d => modDocToHtml module d

View File

@ -27,10 +27,7 @@ def structureToHtml (i : StructureInfo) : HtmlM (Array Html) := do
</ul>
<li «class»="structure_ext_ctor">)</li>
</ul>)
let docstringHtml? ← i.doc.mapM docStringToHtml
match docstringHtml? with
| some d => pure (#[structureHtml] ++ d)
| none => pure #[structureHtml]
pure #[structureHtml]
end Output
end DocGen4