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 def definitionToHtml (i : DefinitionInfo) : HtmlM (Array Html) := do
let equationsHtml? ← equationsToHtml i let equationsHtml? ← equationsToHtml i
let docstringHtml? ← i.doc.mapM docStringToHtml match equationsHtml? with
match equationsHtml?, docstringHtml? with | some e => pure #[e]
| some e, some d => pure (#[e] ++ d) | none => pure #[]
| some e, none => pure #[e]
| none , some d => pure d
| none , none => pure #[]
end Output end Output

View File

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

View File

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

View File

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