Documentation

Lean.Elab.DocString

The internal state used by docstring elaboration

Instances For
    structure Lean.Doc.State :

    The state used by DocM.

    • The command elaboration scope stack.

      These scopes are used when running commands inside of documentation. To keep examples self-contained, these scopes are initialized for each doc comment as if it were the beginning of a Lean file.

    • openDecls : List OpenDecl

      The set of open declarations presently in force.

      The MonadLift TermElabM DocM instance runs the lifted action in a context where these open declarations are used, so elaboration commands that mutate this state cause it to take effect in subsequent commands.

    • The local context.

      The MonadLift TermElabM DocM instance runs the lifted action in this context, so elaboration commands that mutate this state cause it to take effect in subsequent commands.

    • localInstances : LocalInstances

      The local instances.

      The MonadLift TermElabM DocM instance runs the lifted action with these instances, so elaboration commands that mutate this state cause it to take effect in subsequent commands.

    • options : Options

      The options.

      The MonadLift TermElabM DocM instance runs the lifted action with these options, so elaboration commands that mutate this state cause it to take effect in subsequent commands.

    Instances For

      Determines whether docstring suggestions are to be provided as part of editing the string or in a later report.

      • interactive : SuggestionMode

        The user is currently editing the doc comment and can react to suggestions as code actions.

      • batch : SuggestionMode

        The user is not editing the doc comment, and should receive suggestions as summaries.

      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          Context used as a reader in DocM.

          • suggestionMode : SuggestionMode

            Whether suggestions should be provided interactively.

          Instances For
            @[reducible, inline]
            abbrev Lean.Doc.DocM (α : Type) :

            The monad in which documentation is elaborated.

            Equations
            Instances For
              @[instance_reducible]
              Equations
              • One or more equations did not get rendered due to their size.
              @[instance_reducible]
              Equations
              • One or more equations did not get rendered due to their size.
              def Lean.Doc.addDeferredCheck (check : Dynamic) (imports : Array Name) (ref : Syntax) :

              Records a deferred check. Deferred checks represent a docstring task that can't be carried out at the elaboration site, such as resolving a forward reference. Recorded checks include the current namespace, open namespaces, and options, but not the local context.

              The origin site ref is used to record the origin of the deferred check. Returns the check's index within the current docstring, which the docstring's AST stores to refer back to it.

              The saved deferred check is not associated with the docstring or module doc until it is actually added to the environment. After this call, the internal state stores Name.anonymous.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Runs a documentation elaborator in the module docstring context.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  def Lean.Doc.DocM.exec {α : Type} (declName : Name) (binders : Syntax) (act : DocM α) (suggestionMode : SuggestionMode := SuggestionMode.interactive) :

                  Runs a documentation elaborator in a declaration's context, discarding changes made to the environment.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    @[reducible, inline]
                    abbrev Lean.Doc.flag (default : Bool) :

                    Gadget that indicates that a function's parameter should be treated as a Boolean flag when used in a docstring extension.

                    Equations
                    Instances For
                      @[reducible, inline]
                      abbrev Lean.Doc.many (α : Type u) :

                      Gadget that indicates that a function's parameter should be treated as a repeated (and thus optional) named argument when used in a docstring extension.

                      Equations
                      Instances For

                        An argument provided to a docstring extension

                        Instances For
                          @[instance_reducible]
                          Equations
                          • One or more equations did not get rendered due to their size.

                          Returns the syntax from which a documentation argument was drawn, typically used to report errors.

                          Equations
                          Instances For

                            Converts the syntax of a documentation argument into a suitable value.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              structure Lean.Doc.WithSyntax (α : Type u) :

                              A value paired with the syntax it is derived from.

                              This can be used to provide hints and code actions.

                              • val : α

                                The parsed value.

                              • stx : Syntax

                                The syntax that the value was derived from.

                              Instances For

                                A canonical way to convert a documentation extension's argument into a Lean value of type α.

                                • fromDocArg : DocArgElab.TermElabM α

                                  Converts a documentation extension's argument into a Lean value.

                                Instances
                                  def Lean.Doc.getPositional {α : Type} [FromDocArg α] (name : Name) :
                                  StateT (Array (TSyntax `doc_arg)) DocM α

                                  Retrieves the next positional argument from the arguments to a documentation extension. Throws an error if no positional arguments remain.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    def Lean.Doc.getNamed {α : Type} [FromDocArg α] (name : Name) (default : α) :
                                    StateT (Array (TSyntax `doc_arg)) DocM α

                                    Retrieves a named argument from the arguments to a documentation extension. Returns default if no such named argument was provided.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      def Lean.Doc.getMany {α : Type} [FromDocArg α] (name : Name) :
                                      StateT (Array (TSyntax `doc_arg)) DocM (Array α)

                                      Retrieves a repeated named argument from the arguments to a documentation extension.

                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        def Lean.Doc.getFlag (name : Name) (default : Bool) :

                                        Retrieves a flag from the arguments to a documentation extension. Returns default if the flag is not explicit set.

                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For

                                          Asserts that there are no further arguments to a documentation language extension.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For

                                            Environment extension for code suggestions

                                            Environment extension for code block suggestions

                                            Environment extension for docstring roles

                                            @[reducible, inline]

                                            An expander for roles in docstrings.

                                            Equations
                                            Instances For
                                              @[reducible, inline]

                                              An expander for commands in docstrings.

                                              Equations
                                              Instances For
                                                @[reducible, inline]

                                                An expander for directives in docstrings.

                                                Equations
                                                Instances For
                                                  @[reducible, inline]

                                                  An expander for code blocks in docstrings.

                                                  Equations
                                                  Instances For

                                                    Built-in docstring roles, for bootstrapping.

                                                    Environment extension for docstring roles

                                                    Built-in docstring code blocks, for bootstrapping.

                                                    Environment extension for docstring directives

                                                    Built-in docstring directives, for bootstrapping.

                                                    Environment extension for docstring commands

                                                    Built-in docstring commands, for bootstrapping.

                                                    A suggestion about an applicable role

                                                    • role : Name

                                                      The name of the role to suggest.

                                                    • args : Option String

                                                      The arguments it should receive, as a string.

                                                    • moreInfo : Option String

                                                      More information to show users

                                                    Instances For
                                                      @[reducible, inline]

                                                      A provider of suggestions for code elements.

                                                      Equations
                                                      Instances For

                                                        Built-in code suggestions, for bootstrapping

                                                        Adds a builtin documentation code suggestion provider.

                                                        Should be run during initialization.

                                                        Equations
                                                        Instances For
                                                          def Lean.Doc.addBuiltinDocRole (roleName wrapperName : Name) (impl : DocRoleExpander) :

                                                          Adds a builtin documentation role.

                                                          Should be run during initialization.

                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For

                                                            Adds a builtin documentation code block.

                                                            Should be run during initialization.

                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For

                                                              A suggestion about an applicable code block

                                                              • name : Name

                                                                The name of the code block to suggest.

                                                              • args : Option String

                                                                The arguments it should receive, as a string.

                                                              • moreInfo : Option String

                                                                More information to show users

                                                              Instances For
                                                                @[reducible, inline]

                                                                A provider of suggestions for code elements.

                                                                Equations
                                                                Instances For

                                                                  Built-in code block suggestions, for bootstrapping

                                                                  Adds a builtin documentation code suggestion provider.

                                                                  Should be run during initialization.

                                                                  Equations
                                                                  Instances For
                                                                    def Lean.Doc.addBuiltinDocDirective (directiveName wrapper : Name) (impl : DocDirectiveExpander) :

                                                                    Adds a builtin documentation directive.

                                                                    Should be run during initialization.

                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For
                                                                      def Lean.Doc.addBuiltinDocCommand (commandName wrapper : Name) (impl : DocCommandExpander) :

                                                                      Adds a builtin documentation command.

                                                                      Should be run during initialization.

                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For
                                                                        partial def Lean.Doc.elabInline (stx : TSyntax `inline) :

                                                                        Elaborates the syntax of an inline document element to an actual inline document element.

                                                                        Elaborates the syntax of an block-level document element to an actual block-level document element.

                                                                        Elaborates a sequence of blocks into a document.

                                                                        Equations
                                                                        • One or more equations did not get rendered due to their size.
                                                                        Instances For
                                                                          def Lean.Doc.elabModSnippet (range : DeclarationRange) (blocks : TSyntaxArray `block) (nestingLevel : Nat) :

                                                                          Elaborates a sequence of blocks into a module doc snippet.

                                                                          Equations
                                                                          Instances For
                                                                            def Lean.Doc.registerDocMVar (extension : Name) (e : Expr) (ref : Syntax) (location : MessageData) :

                                                                            Registers a single MVarErrorInfo so that, if any metavariable in e remains unresolved at the end of document elaboration, one error is emitted at ref naming the documentation extension (the constant implementing the role/code block, e.g. Lean.Doc.given) and the supplied location (e.g. "type of variable xs") that contained the hole. The element name is rendered via docElementMessage. Roles and code blocks use this to attach a diagnostic to the syntax that introduced the variable, in addition to the standard placeholder errors that the underlying elaborator emits for unsolved metas.

                                                                            Equations
                                                                            • One or more equations did not get rendered due to their size.
                                                                            Instances For