diff --git a/DocGen4/Output/Inductive.lean b/DocGen4/Output/Inductive.lean index 85fcda0..0a05403 100644 --- a/DocGen4/Output/Inductive.lean +++ b/DocGen4/Output/Inductive.lean @@ -6,8 +6,9 @@ namespace Output open scoped DocGen4.Jsx def ctorToHtml (i : NameInfo) : HtmlM Html := do - let name := i.name.components'.head!.toString - return
  • {name} : [←infoFormatToHtml i.type]
  • + let shortName := i.name.components'.head!.toString + let name := i.name.toString + return
  • {shortName} : [←infoFormatToHtml i.type]
  • def inductiveToHtml (i : InductiveInfo) : HtmlM (Array Html) := do #[Html.element "ul" false #[("class", "constructors")] (←i.ctors.toArray.mapM ctorToHtml)] diff --git a/DocGen4/Output/Structure.lean b/DocGen4/Output/Structure.lean index af5eeb4..2c5b76d 100644 --- a/DocGen4/Output/Structure.lean +++ b/DocGen4/Output/Structure.lean @@ -6,7 +6,9 @@ namespace Output open scoped DocGen4.Jsx def fieldToHtml (f : NameInfo) : HtmlM Html := do - return
  • {s!"{f.name} : "} [←infoFormatToHtml f.type]
  • + let shortName := f.name.components'.head!.toString + let name := f.name.toString + return
  • {shortName} : [←infoFormatToHtml f.type]
  • def structureToHtml (i : StructureInfo) : HtmlM (Array Html) := do #[Html.element "ul" false #[("class", "structure_fields"), ("id", s!"{i.name.toString}.mk")] (←i.fieldInfo.mapM fieldToHtml)] diff --git a/DocGen4/Process.lean b/DocGen4/Process.lean index 3839c3a..dc5d954 100644 --- a/DocGen4/Process.lean +++ b/DocGen4/Process.lean @@ -182,13 +182,13 @@ def dropArgs (type : Expr) (n : Nat) : (Expr × List (Name × Expr)) := { next with snd := (name, type) :: next.snd} | e, x + 1 => panic! s!"No forallE left" -def getFieldTypes (ctor : ConstructorVal) (parents : Nat) : MetaM (Array NameInfo) := do +def getFieldTypes (struct : Name) (ctor : ConstructorVal) (parents : Nat) : MetaM (Array NameInfo) := do let type := ctor.type let (field_function, params) := dropArgs type (ctor.numParams + parents) let (_, fields) := dropArgs field_function (ctor.numFields - parents) let mut field_infos := #[] for (name, type) in fields do - field_infos := field_infos.push { name := name, type := ←prettyPrintTerm type} + field_infos := field_infos.push { name := struct.append name, type := ←prettyPrintTerm type} field_infos def StructureInfo.ofInductiveVal (v : InductiveVal) : MetaM StructureInfo := do @@ -200,7 +200,7 @@ def StructureInfo.ofInductiveVal (v : InductiveVal) : MetaM StructureInfo := do match getStructureInfo? env v.name with | some i => if i.fieldNames.size - parents.size > 0 then - return StructureInfo.mk info (←getFieldTypes ctor parents.size) parents ⟨ctor.name, ctorType⟩ + return StructureInfo.mk info (←getFieldTypes v.name ctor parents.size) parents ⟨ctor.name, ctorType⟩ else return StructureInfo.mk info #[] parents ⟨ctor.name, ctorType⟩ | none => panic! s!"{v.name} is not a structure"