Rendered Code #
Lean's pretty printer produces CodeWithInfos (a TaggedText SubexprInfo), which carries rich
metadata such as expression types, universe levels, elaboration state, etc. This is too large to
serialize to disk.
RenderedCode is a TaggedText RenderedCode.Tag that keeps only the information needed for HTML
rendering: which tokens are declaration references (for linking), which are sorts (for linking to
the foundational types page), and which are keywords or strings (for syntax highlighting). The
conversion from CodeWithInfos to RenderedCode happens in renderTagged at the bottom of this
file.
RenderedCode is serialized to the database as a binary blob via ToBinary/FromBinary instances.
If the RenderedCode.Tag or TaggedText types change, the type hash in DocGen4.DB.Schema will
detect the mismatch and require a rebuild.
Used in RenderedCode.Tag to track what kind of sort this is.
- type : SortFormer
- prop : SortFormer
- sort : SortFormer
Instances For
Equations
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Equations
- DocGen4.instBEqSortFormer.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
- DocGen4.instReprSortFormer.repr DocGen4.SortFormer.type prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "DocGen4.SortFormer.type")).group prec✝
- DocGen4.instReprSortFormer.repr DocGen4.SortFormer.prop prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "DocGen4.SortFormer.prop")).group prec✝
- DocGen4.instReprSortFormer.repr DocGen4.SortFormer.sort prec✝ = Repr.addAppParen (Std.Format.nest (if prec✝ ≥ 1024 then 1 else 2) (Std.Format.text "DocGen4.SortFormer.sort")).group prec✝
Instances For
Equations
- DocGen4.instReprSortFormer = { reprPrec := DocGen4.instReprSortFormer.repr }
Equations
Equations
- DocGen4.RenderedCode.instBEqTag.beq DocGen4.RenderedCode.Tag.keyword DocGen4.RenderedCode.Tag.keyword = true
- DocGen4.RenderedCode.instBEqTag.beq DocGen4.RenderedCode.Tag.string DocGen4.RenderedCode.Tag.string = true
- DocGen4.RenderedCode.instBEqTag.beq (DocGen4.RenderedCode.Tag.const a) (DocGen4.RenderedCode.Tag.const b) = (a == b)
- DocGen4.RenderedCode.instBEqTag.beq (DocGen4.RenderedCode.Tag.sort a) (DocGen4.RenderedCode.Tag.sort b) = (a == b)
- DocGen4.RenderedCode.instBEqTag.beq DocGen4.RenderedCode.Tag.otherExpr DocGen4.RenderedCode.Tag.otherExpr = true
- DocGen4.RenderedCode.instBEqTag.beq x✝¹ x✝ = false
Instances For
Equations
- DocGen4.RenderedCode.instHashableTag.hash DocGen4.RenderedCode.Tag.keyword = 0
- DocGen4.RenderedCode.instHashableTag.hash DocGen4.RenderedCode.Tag.string = 1
- DocGen4.RenderedCode.instHashableTag.hash (DocGen4.RenderedCode.Tag.const a) = mixHash 2 (hash a)
- DocGen4.RenderedCode.instHashableTag.hash (DocGen4.RenderedCode.Tag.sort a) = mixHash 3 (hash a)
- DocGen4.RenderedCode.instHashableTag.hash DocGen4.RenderedCode.Tag.otherExpr = 4
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
Equations
Equations
A simplified representation of code with semantic tags for rendering.
Unlike CodeWithInfos, this only contains the information needed for HTML rendering
(links to declarations, syntax highlighting) and can be serialized to/from the database.
Instances For
Equations
Equations
Equations
Equations
Equations
- DocGen4.instFromBinaryRenderedCode = { deserializer := DocGen4.instFromBinaryRenderedCode._aux_1 }
Equations
Instances For
Equations
In Lean syntax declarations the following pattern is quite common:
syntax term " + " term : term
that is, we place spaces around the operator in the middle. When the
InfoTree framework provides us with information about what source token
corresponds to which identifier it will thus say that " + " corresponds to
HAdd.hadd. This is however not the way we want this to be linked, in the HTML
only + should be linked, taking care of this is what this function is
responsible for.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Convert CodeWithInfos (from Lean's pretty printer) to RenderedCode
by extracting only the information needed for HTML rendering.