commit
eae71c61a3
|
@ -0,0 +1,26 @@
|
||||||
|
import DocGen4.Output.Template
|
||||||
|
import DocGen4.Output.Structure
|
||||||
|
|
||||||
|
namespace DocGen4
|
||||||
|
namespace Output
|
||||||
|
|
||||||
|
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
|
||||||
|
(←structureToHtml i.toStructureInfo).push (←instancesToHtml i)
|
||||||
|
|
||||||
|
end Output
|
||||||
|
end DocGen4
|
|
@ -6,6 +6,7 @@ Authors: Henrik Böving
|
||||||
import DocGen4.Output.Template
|
import DocGen4.Output.Template
|
||||||
import DocGen4.Output.Inductive
|
import DocGen4.Output.Inductive
|
||||||
import DocGen4.Output.Structure
|
import DocGen4.Output.Structure
|
||||||
|
import DocGen4.Output.Class
|
||||||
|
|
||||||
namespace DocGen4
|
namespace DocGen4
|
||||||
namespace Output
|
namespace Output
|
||||||
|
@ -59,8 +60,11 @@ def docInfoHeader (doc : DocInfo) : HtmlM Html := do
|
||||||
for arg in doc.getArgs do
|
for arg in doc.getArgs do
|
||||||
nodes := nodes.push (←argToHtml arg)
|
nodes := nodes.push (←argToHtml arg)
|
||||||
|
|
||||||
if let DocInfo.structureInfo i := doc then
|
-- TODO: dedup this
|
||||||
nodes := nodes.append (←structureInfoHeader i)
|
match doc with
|
||||||
|
| DocInfo.structureInfo i => nodes := nodes.append (←structureInfoHeader i)
|
||||||
|
| DocInfo.classInfo i => nodes := nodes.append (←structureInfoHeader i.toStructureInfo)
|
||||||
|
| _ => nodes := nodes
|
||||||
|
|
||||||
nodes := nodes.push <span «class»="decl_args">:</span>
|
nodes := nodes.push <span «class»="decl_args">:</span>
|
||||||
nodes := nodes.push $ Html.element "div" true #[("class", "decl_type")] (←infoFormatToHtml doc.getType)
|
nodes := nodes.push $ Html.element "div" true #[("class", "decl_type")] (←infoFormatToHtml doc.getType)
|
||||||
|
@ -70,6 +74,7 @@ def docInfoToHtml (doc : DocInfo) : HtmlM Html := do
|
||||||
let doc_html ← match doc with
|
let doc_html ← 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
|
||||||
| _ => #[]
|
| _ => #[]
|
||||||
|
|
||||||
return <div «class»="decl" id={doc.getName.toString}>
|
return <div «class»="decl" id={doc.getName.toString}>
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,7 @@ main h2, main h3, main h4, main h5, main h6 {
|
||||||
margin-top: 4rem;
|
margin-top: 4rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.def {
|
.def, .instance {
|
||||||
border-left: 10px solid #92dce5;
|
border-left: 10px solid #92dce5;
|
||||||
border-top: 2px solid #92dce5;
|
border-top: 2px solid #92dce5;
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ main h2, main h3, main h4, main h5, main h6 {
|
||||||
border-top: 2px solid #f44708;
|
border-top: 2px solid #f44708;
|
||||||
}
|
}
|
||||||
|
|
||||||
.structure, .inductive {
|
.structure, .inductive, .class {
|
||||||
border-left: 10px solid #f0a202;
|
border-left: 10px solid #f0a202;
|
||||||
border-top: 2px solid #f0a202;
|
border-top: 2px solid #f0a202;
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,7 @@ main h2, main h3, main h4, main h5, main h6 {
|
||||||
transition: background-color 100ms ease-in-out;
|
transition: background-color 100ms ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.def .fn:hover {
|
.def .fn:hover, .instance .fn:hover {
|
||||||
background-color: hsla(187, 61%, calc(100% - 5%*var(--fn)));
|
background-color: hsla(187, 61%, calc(100% - 5%*var(--fn)));
|
||||||
box-shadow: 0 0 0 1px hsla(187, 61%, calc(100% - 5%*(var(--fn) + 1)));
|
box-shadow: 0 0 0 1px hsla(187, 61%, calc(100% - 5%*(var(--fn) + 1)));
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
@ -415,7 +415,7 @@ main h2, main h3, main h4, main h5, main h6 {
|
||||||
box-shadow: 0 0 0 1px hsla(16, 94%, calc(100% - 5%*(var(--fn) + 1)));
|
box-shadow: 0 0 0 1px hsla(16, 94%, calc(100% - 5%*(var(--fn) + 1)));
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
.structure .fn:hover, .inductive .fn:hover {
|
.structure .fn:hover, .inductive .fn:hover, .class .fn:hover {
|
||||||
background-color: hsla(40, 98%, calc(100% - 5%*var(--fn)));
|
background-color: hsla(40, 98%, calc(100% - 5%*var(--fn)));
|
||||||
box-shadow: 0 0 0 1px hsla(40, 98%, calc(100% - 5%*(var(--fn) + 1)));
|
box-shadow: 0 0 0 1px hsla(40, 98%, calc(100% - 5%*(var(--fn) + 1)));
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
|
Loading…
Reference in New Issue