Documentation

Lean.DocString.Extension

Saved data that describes a custom inline element.

The type of value contained within the Dynamic determines the interpretation of the custom element, including how it is rendered to Markdown for the language server.

  • custom (val : Dynamic) : ElabInline

    A custom inline element. The type of the value in the Dynamic determines how it is interpreted and rendered.

  • deferred (index : Nat) : ElabInline

    A deferred check that lacked sufficient information when it was used (e.g. a forward references to a name in a downstream module). The index identifies it among the docstring's deferred checks that are stored in an environment extension. Inline and block deferred checks use the same counter.

Instances For
    @[instance_reducible]
    inductive Lean.ElabBlock :

    Saved data that describes a custom block element.

    The type of value contained within the Dynamic determines the interpretation of the custom element, including how it is rendered to Markdown for the language server.

    • custom (val : Dynamic) : ElabBlock

      A custom block element. The type of the value in the Dynamic determines how it is interpreted and rendered.

    • deferred (index : Nat) : ElabBlock

      A deferred check that lacked sufficient information when it was used (e.g. a forward references to a name in a downstream module). The index identifies it among the docstring's deferred checks that are stored in an environment extension. Inline and block deferred checks use the same counter.

    Instances For
      @[instance_reducible]
      @[inline]
      def Lean.Doc.Inline.custom {α : Type u_1} [TypeName α] (val : α) (content : Array (Inline ElabInline)) :

      A custom inline element val. The type α determines how it is interpreted. In contexts where α is not understood, content is used as a fallback.

      Instances For
        @[inline]

        An inline element with a deferred check. The index is a 0-based index into the current docstring's deferred checks, in source order. Block and inline deferred elements share a counter.

        Instances For
          @[inline]

          A custom block element val. The type α determines how it is interpreted. In contexts where α is not understood, content is used as a fallback.

          Instances For
            @[inline]

            A block element with a deferred check. The index is a 0-based index into the current docstring's deferred checks, in source order. Block and inline deferred elements share a counter.

            Instances For
              def Lean.addBuiltinDocString (declName : Name) (docString : String) :

              Adds a builtin docstring to the compiler.

              The text should have already had its leading indentation removed by the caller.

              Links to the Lean manual aren't validated.

              Instances For

                Removes a builtin docstring from the compiler. This is used when translating between formats.

                Instances For

                  Retrieves all builtin Verso docstrings.

                  Instances For
                    def Lean.throwIfHasDocString {m : Type → Type} [Monad m] [MonadError m] [MonadEnv m] (declName : Name) :

                    Throws if declName already has a Markdown or Verso docstring.

                    Instances For
                      def Lean.addDocStringCore {m : Type → Type} [Monad m] [MonadError m] [MonadEnv m] [MonadLiftT BaseIO m] (declName : Name) (docString : String) :

                      Sets the docstring of declName, replacing an existing one: metaprograms extend docstrings this way (e.g. by appending cross-reference links). Only add_decl_doc rejects a second docstring.

                      Instances For
                        def Lean.removeDocStringCore {m : Type → Type} [Monad m] [MonadError m] [MonadEnv m] [MonadLiftT BaseIO m] (declName : Name) :
                        Instances For
                          def Lean.addDocStringCore' {m : Type → Type} [Monad m] [MonadError m] [MonadEnv m] [MonadLiftT BaseIO m] (declName : Name) (docString? : Option String) :
                          Instances For
                            partial def Lean.findInternalDocString? (env : Environment) (declName : Name) (includeBuiltin : Bool := true) :

                            Finds a docstring without performing any alias resolution or enrichment with extra metadata. For Markdown docstrings, the result is a string; for Verso docstrings, it's a VersoDocString.

                            Docstrings to be shown to a user should be looked up with Lean.findDocString? instead.

                            def Lean.addInheritedDocString {m : Type → Type} [Monad m] [MonadError m] [MonadEnv m] [MonadLiftT IO m] (declName target : Name) :
                            Instances For
                              structure Lean.ModuleDoc :
                              Instances For
                                Instances For
                                  def Lean.getDocStringText {m : Type → Type} [Monad m] [MonadError m] (stx : TSyntax `Lean.Parser.Command.docComment) :
                                  Instances For
                                    def Lean.isVersoDocComment (stx : TSyntax `Lean.Parser.Command.docComment) :

                                    Checks whether stx is a docstring that was parsed as Verso rather than Markdown.

                                    Instances For

                                      A snippet of a Verso module text.

                                      A snippet consists of text followed by subsections. Because the sequence of snippets that occur in a source file are conceptually a single document, they have a consistent header nesting structure. This means that initial textual content of a snippet is a continuation of the text at the end of the prior snippet.

                                      The actual hierarchical structure of the document is reconstructed from the sequence of snippets.

                                      The terminal nesting of a sequence of snippets is 0 if there are no sections in the sequence. Otherwise, it is one greater than the nesting of the last snippet's last section. The module docstring elaborator maintains the invariant that each snippet's first section's level is at most the terminal nesting of the preceding snippets, and that the level of each section within a snippet is at most one greater than the preceding section's level.

                                      Instances For
                                        Instances For
                                          Instances For
                                            Instances For

                                              Returns the Verso module docs for the current main module.

                                              During elaboration, this will return the modules docs that have been added thus far, rather than those for the entire module.

                                              Instances For
                                                @[deprecated Lean.getMainVersoModuleDocs (since := "2026-01-21")]
                                                Instances For

                                                  Returns all snippets of the Verso module docs from the indicated module, if they exist.

                                                  Instances For