Verso Docstring Serialization #
Verso docstrings (VersoDocString) contain a tree of Doc.Block/Doc.Inline nodes, which can
include extension points (ElabInline/ElabBlock) which are opaque Dynamic values identified by
Name. Different Lean packages can register their own extension types, so we can't know all
possible types ahead of time.
The serialization strategy is:
- For each
ElabInline/ElabBlock, look up a handler by name inDocstringValues. - If a handler exists, serialize the payload with it. On deserialization, the same handler reconstructs the value.
- If no handler exists (the extension type is unknown), serialize just the name (tag byte
0). On deserialization, unknown extensions are replaced with anUnknownsentinel value and their payload bytes are skipped. This means the database remains readable even if extension types are not available to a client. In Verso docstrings, the content underneath a custom inline or block node represents an alternative “plain” representation, such as a generic code element instead of semantically-highlighted Lean code.
builtinDocstringValues (defined at the bottom of this file) registers the handlers for extension
types that ship with Lean. If a downstream package defines custom Verso extensions, it would need to
provide its own DocstringValues with additional handlers. There's presently no API for this, but
the code is designed to allow plugins that provide handlers in the future.
Serializer/deserializer pair for a single Verso extension type.
- serialize : SQLite.Blob.Serializer Dynamic
- deserialize : SQLite.Blob.Deserializer Dynamic
Instances For
Registry of known Verso extension types, keyed by Name.
- handlers : Lean.NameMap DocstringDataHandler
Instances For
Equations
- DocGen4.DB.toBinaryElabInline vals { name := name, val := val } x✝ = DocGen4.DB.toBinaryElab✝ vals name val x✝
Instances For
Equations
- DocGen4.DB.toBinaryElabBlock vals { name := name, val := val } x✝ = DocGen4.DB.toBinaryElab✝ vals name val x✝
Instances For
Equations
Equations
- DocGen4.DB.instBEqUnknown.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
Instances For
Equations
- DocGen4.DB.instOrdUnknown = { compare := DocGen4.DB.instOrdUnknown.ord }
Equations
- DocGen4.DB.instOrdUnknown.ord x✝ y✝ = compare x✝.ctorIdx y✝.ctorIdx
Instances For
Equations
Equations
- DocGen4.DB.fromBinaryElabInline vals = do let __discr ← DocGen4.DB.fromBinaryElab✝ vals "ElabInline" match __discr with | (name, val) => pure { name := name, val := val }
Instances For
Equations
- DocGen4.DB.fromBinaryElabBlock vals = do let __discr ← DocGen4.DB.fromBinaryElab✝ vals "ElabBlock" match __discr with | (name, val) => pure { name := name, val := val }
Instances For
Equations
Equations
Equations
Equations
Equations
Equations
- DocGen4.DB.instFromBinaryPart_docGen4 = { deserializer := DocGen4.DB.instFromBinaryPart_docGen4.go }
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.
Instances For
Equations
Instances For
Builtin Data.* handlers #
Equations
Equations
- One or more equations did not get rendered due to their size.
- DocGen4.DB.instToBinaryPreresolved_docGen4.toBinaryAux (Lean.Syntax.Preresolved.namespace f_0) x✝ = SQLite.Blob.ToBinary.serializer f_0 (SQLite.Blob.ToBinary.serializer 0 x✝)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Equations
Equations
- DocGen4.DB.instToBinaryDataValue_docGen4.toBinaryAux (Lean.DataValue.ofString f_0) x✝ = SQLite.Blob.ToBinary.serializer f_0 (SQLite.Blob.ToBinary.serializer 0 x✝)
- DocGen4.DB.instToBinaryDataValue_docGen4.toBinaryAux (Lean.DataValue.ofBool f_0) x✝ = SQLite.Blob.ToBinary.serializer f_0 (SQLite.Blob.ToBinary.serializer 1 x✝)
- DocGen4.DB.instToBinaryDataValue_docGen4.toBinaryAux (Lean.DataValue.ofName f_0) x✝ = SQLite.Blob.ToBinary.serializer f_0 (SQLite.Blob.ToBinary.serializer 2 x✝)
- DocGen4.DB.instToBinaryDataValue_docGen4.toBinaryAux (Lean.DataValue.ofNat f_0) x✝ = SQLite.Blob.ToBinary.serializer f_0 (SQLite.Blob.ToBinary.serializer 3 x✝)
- DocGen4.DB.instToBinaryDataValue_docGen4.toBinaryAux (Lean.DataValue.ofInt f_0) x✝ = SQLite.Blob.ToBinary.serializer f_0 (SQLite.Blob.ToBinary.serializer 4 x✝)
- DocGen4.DB.instToBinaryDataValue_docGen4.toBinaryAux (Lean.DataValue.ofSyntax f_0) x✝ = SQLite.Blob.ToBinary.serializer f_0 (SQLite.Blob.ToBinary.serializer 5 x✝)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- DocGen4.DB.instToBinaryKVMap_docGen4.toBinaryAux { entries := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
Equations
Equations
- DocGen4.DB.instFromBinaryKVMap_docGen4.fromBinaryAux = (fun (f_0 : List (Lean.Name × Lean.DataValue)) => { entries := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
Equations
Equations
- One or more equations did not get rendered due to their size.
- DocGen4.DB.instToBinaryDocHighlight_docGen4.toBinaryAux Lean.Doc.DocHighlight.keyword x✝ = SQLite.Blob.ToBinary.serializer 4 x✝
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- DocGen4.DB.instToBinaryDocCode_docGen4.toBinaryAux { code := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
Equations
- DocGen4.DB.instFromBinaryDocCode_docGen4.fromBinaryAux = (fun (f_0 : Array (String × Option Lean.Doc.DocHighlight)) => { code := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
Equations
Equations
- DocGen4.DB.instToBinaryConst_docGen4.toBinaryAux { name := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
Equations
- DocGen4.DB.instFromBinaryConst_docGen4.fromBinaryAux = (fun (f_0 : Lean.Name) => { name := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
- DocGen4.DB.instToBinaryTactic_docGen4.toBinaryAux { name := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
Equations
Equations
- DocGen4.DB.instFromBinaryTactic_docGen4.fromBinaryAux = (fun (f_0 : Lean.Name) => { name := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
Equations
- DocGen4.DB.instToBinaryConvTactic_docGen4.toBinaryAux { name := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
- DocGen4.DB.instFromBinaryConvTactic_docGen4.fromBinaryAux = (fun (f_0 : Lean.Name) => { name := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
Equations
- DocGen4.DB.instToBinarySyntaxCat_docGen4.toBinaryAux { name := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
- DocGen4.DB.instFromBinarySyntaxCat_docGen4.fromBinaryAux = (fun (f_0 : Lean.Name) => { name := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
Equations
- DocGen4.DB.instToBinaryModuleName_docGen4.toBinaryAux { module := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
Equations
- DocGen4.DB.instFromBinaryModuleName_docGen4.fromBinaryAux = (fun (f_0 : Lean.Name) => { module := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
Equations
- DocGen4.DB.instToBinaryOption_docGen4.toBinaryAux { name := f_0, declName := f_1 } x✝ = SQLite.Blob.ToBinary.serializer f_1 (SQLite.Blob.ToBinary.serializer f_0 x✝)
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- DocGen4.DB.instToBinaryAttributes_docGen4.toBinaryAux { stx := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
Equations
- DocGen4.DB.instFromBinaryAttributes_docGen4.fromBinaryAux = (fun (f_0 : Lean.Syntax) => { stx := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
Equations
- DocGen4.DB.instToBinaryAttribute_docGen4.toBinaryAux { stx := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
Equations
- DocGen4.DB.instFromBinaryAttribute_docGen4.fromBinaryAux = (fun (f_0 : Lean.Syntax) => { stx := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
Equations
- DocGen4.DB.instToBinarySyntax_docGen4_1.toBinaryAux { category := f_0, stx := f_1 } x✝ = SQLite.Blob.ToBinary.serializer f_1 (SQLite.Blob.ToBinary.serializer f_0 x✝)
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- DocGen4.DB.instToBinaryLeanBlock_docGen4.toBinaryAux { commands := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
Equations
- DocGen4.DB.instFromBinaryLeanBlock_docGen4.fromBinaryAux = (fun (f_0 : Lean.Doc.DocCode) => { commands := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
Equations
- DocGen4.DB.instToBinaryLeanTerm_docGen4.toBinaryAux { term := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
Equations
- DocGen4.DB.instFromBinaryLeanTerm_docGen4.fromBinaryAux = (fun (f_0 : Lean.Doc.DocCode) => { term := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
- DocGen4.DB.instToBinarySetOption_docGen4.toBinaryAux { term := f_0 } x✝ = SQLite.Blob.ToBinary.serializer f_0 x✝
Instances For
Equations
Equations
- DocGen4.DB.instFromBinarySetOption_docGen4.fromBinaryAux = (fun (f_0 : Lean.Doc.DocCode) => { term := f_0 }) <$> SQLite.Blob.FromBinary.deserializer
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.