feat: list instances of classes
parent
87f959e11d
commit
b777250338
|
@ -5,9 +5,22 @@ namespace DocGen4
|
||||||
namespace Output
|
namespace Output
|
||||||
|
|
||||||
open scoped DocGen4.Jsx
|
open scoped DocGen4.Jsx
|
||||||
|
open Lean
|
||||||
|
|
||||||
|
def instanceToHtml (name : Name) : HtmlM Html := do
|
||||||
|
<li><a href={←declNameToLink name}>{name.toString}</a></li>
|
||||||
|
|
||||||
|
def instancesToHtml (i : ClassInfo) : HtmlM Html := do
|
||||||
|
let instancesHtml ← i.instances.mapM instanceToHtml
|
||||||
|
return <details «class»="instances">
|
||||||
|
<summary>Instances</summary>
|
||||||
|
<ul>
|
||||||
|
[instancesHtml]
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
|
||||||
def classToHtml (i : ClassInfo) : HtmlM (Array Html) := do
|
def classToHtml (i : ClassInfo) : HtmlM (Array Html) := do
|
||||||
structureToHtml i.toStructureInfo
|
(←structureToHtml i.toStructureInfo).push (←instancesToHtml i)
|
||||||
|
|
||||||
end Output
|
end Output
|
||||||
end DocGen4
|
end DocGen4
|
||||||
|
|
|
@ -63,8 +63,7 @@ structure StructureInfo extends Info where
|
||||||
deriving Inhabited
|
deriving Inhabited
|
||||||
|
|
||||||
structure ClassInfo extends StructureInfo where
|
structure ClassInfo extends StructureInfo where
|
||||||
hasOutParam : Bool
|
instances : Array Name
|
||||||
instances : Array CodeWithInfos
|
|
||||||
deriving Inhabited
|
deriving Inhabited
|
||||||
|
|
||||||
inductive DocInfo where
|
inductive DocInfo where
|
||||||
|
@ -193,8 +192,7 @@ def ClassInfo.ofInductiveVal (v : InductiveVal) : MetaM ClassInfo := do
|
||||||
let fn ← mkConstWithFreshMVarLevels v.name
|
let fn ← mkConstWithFreshMVarLevels v.name
|
||||||
let (xs, _, _) ← forallMetaTelescopeReducing (← inferType fn)
|
let (xs, _, _) ← forallMetaTelescopeReducing (← inferType fn)
|
||||||
let insts ← SynthInstance.getInstances (mkAppN fn xs)
|
let insts ← SynthInstance.getInstances (mkAppN fn xs)
|
||||||
let insts_stx ← insts.mapM prettyPrintTerm
|
return ClassInfo.mk sinfo (insts.map Expr.constName!)
|
||||||
return ClassInfo.mk sinfo (hasOutParams (←getEnv) v.name) insts_stx
|
|
||||||
|
|
||||||
namespace DocInfo
|
namespace DocInfo
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue