Documentation

Lean.DocString.Parser

A parser that does nothing.

Instances For

    Whether c may appear in the name of a footnote or a link reference. A name is written literally, so a backslash denotes itself elsewhere and is not part of a name.

    Instances For

      Parses as p, but discards the result.

      Instances For

        Consumes the whitespace that separates a block from what follows it: the rest of the current line, any blank lines, and the indentation of the line where content resumes.

        Tabs are not valid whitespace characters, so they are not consumed. The next block actually throws the error.

        Instances For

          Matches an arbitrary parser and pushes the consumed input as a Syntax.atom. The trailing parser runs after the token's content, and the input it consumes becomes the token's trailing whitespace.

          Instances For

            Ordered lists may have two styles of marker, with trailing dots or parentheses.

            Instances For

              Unordered lists may have three markers: asterisks, dashes, or pluses.

              Instances For

                Parses a character that's allowed as part of inline text. This resolves escaped characters and performs limited lookahead for characters that only begin a different inline as part of a sequence.

                Instances For

                  Parses block opener prefixes. If this parser succeeds at the beginning of a line, then a special block is beginning.

                  Instances For

                    Parses an argument value, which may be a string, an identifier, or a numeral. The value's token records the input consumed by trailing as its trailing whitespace.

                    Instances For

                      Runs p, and on failure consumes input with recover until parsing may continue. The error is recorded where p stopped, so that it marks the input that could not be read rather than the input that recovery passed over.

                      Instances For

                        The whitespace after an argument, recorded on the argument's last token as its trailing whitespace: the spaces that follow it.

                        Instances For
                          def Lean.Doc.Parser.argFn (tail : Parser.ParserFn := skipFn) (closes : Char → Bool := fun (x : Char) => false) :

                          Parses an argument to a role, directive, command, or code block, which may be named or positional or a flag. The argument's final token records the input tail consumes as its trailing whitespace.

                          Error recovery stops at characters that satisfy closes, which should delimit the current argument list (e.g. via a role's }).

                          Instances For
                            def Lean.Doc.Parser.argsFn (tail : Parser.ParserFn := argEndWs) (closes : Char → Bool := fun (x : Char) => false) :

                            Parses zero or more arguments to a role, directive, command, or code block. Each argument's final token records the input tail consumes as its trailing whitespace. The argument list must be on the line the parser starts on. A starting position at the beginning of a line means the list has already ended, so the list is empty.

                            Error recovery stops at characters that satisfy closes, which should delimit the current argument list (e.g. via a role's }).

                            Instances For

                              Parses a name and zero or more arguments to a role, directive, command, or code block. The final token of the name and of each argument records the input that tail consumes as its trailing whitespace. The name and arguments must be on the line the parser starts on. A starting position at the beginning of a line fails to parse a name.

                              The caller's own tokens record the whitespace before the name. If a caller lets this parser consume that whitespace instead, no token records it.

                              Error recovery stops at characters that satisfy closes, which should delimit the current argument list (e.g. via a role's }).

                              Instances For

                                The context within which a newline element is parsed.

                                • allowNewlines : Bool

                                  Are newlines allowed here?

                                • boldDepth : Option Nat

                                  How many asterisks introduced the current level of boldness? none means no bold here.

                                • emphDepth : Option Nat

                                  How many underscores introduced the current level of emphasis? none means no emphasis here.

                                • The trailing whitespace parser for the final token of a top-level inline element.

                                • baseColumn : Nat

                                  The docstring's base column, which allows inline code and math to be parsed relative to the docstring's indentation.

                                Instances For

                                  Parses emphasis: a matched pair of one or more _.

                                  Parses bold: a matched pair of one or more *.

                                  Parses inline code. The content is one versoCodeLine token per source line. Each line's token records the docstring's indentation on the line after it as trailing whitespace, while indentation past that column is part of the code. A space written at each end of the content to escape a backtick or a space becomes whitespace on the token before it.

                                  Instances For

                                    Parses mathematics. The content is inline code, with its lines and indentation read the same way.

                                    Instances For

                                      Reads a prefix of a line of text, stopping at a text-mode special character.

                                      Instances For

                                        Parses a link.

                                        Parses a footnote.

                                        Instances For

                                          Parses an image.

                                          Instances For

                                            Parses a role.

                                            Parses an inline that is self-delimiting (that is, with well-defined start and stop characters).

                                            Parses any inline element.

                                            def Lean.Doc.Parser.textLineFn (ctxt : InlineCtxt := { }) (recordTrailing : Bool := false) :

                                            Parses a line of text (that is, one or more inline elements). When recordTrailing is set, each top-level inline's final token consumes the whitespace that follows it as its trailing whitespace.

                                            Instances For

                                              The fields of a metadata block, which are the fields of a structure instance.

                                              Instances For

                                                The style of a list, shared by all of its items.

                                                Instances For

                                                  The context within which a block should be valid.

                                                  • topLevel : Bool

                                                    Whether blocks in this context are at the document's top level, rather than the contents of another block.

                                                  • recordTrailing : Bool

                                                    Whether each block's final token records the whitespace that follows the block as its trailing whitespace.

                                                  • maxDirective : Option Nat

                                                    The block's maximal directive size (that is, the greatest number of allowed colons).

                                                  • docStartPosition : Position

                                                    The position at which the document content starts, used to allow headers on the first line of a docstring (e.g. /-! # Header -/). With the default value ⟨1, 0⟩, the beginning-of-line check is unaffected for normal documents.

                                                  • baseColumn : Nat

                                                    The base column of the docstring, which is the least indentation of any non-empty line in it, including the opening and closing delimiters. Items that may not nest in blocks, such as headers, start at this column, and a code element's lines treat the indentation up to it as whitespace.

                                                  Instances For

                                                    Computes the BlockCtxt for parsing a docstring whose opening delimiter is at openPos and whose content begins at startPos, on the line where that content starts and separated from it by spaces alone. endPos is the position of the - before the / in the closing delimiter.

                                                    When the docstring content starts mid-line (e.g. /-! # Header -/), the docStartPosition is set to the position after any leading spaces so that headers on the first line are recognized. For indented docstrings, baseColumn is computed as the minimum column among the opening delimiter, the closing delimiter, and the least-indented non-empty content line.

                                                    Instances For

                                                      Parses a metadata block, which contains the contents of a Lean structure initialization but is surrounded by %%% on each side.

                                                      Instances For

                                                        Succeeds when the parser is looking at an ordered list marker.

                                                        Instances For

                                                          Succeeds when the parser is looking at an unordered list marker.

                                                          Instances For

                                                            Sets the leading whitespace of the first token in stx to run from startPos. Syntax without tokens stays unchanged.

                                                            Every token that a parse produces has empty leading whitespace, because the token before it records the whitespace between them. The first token of an input records the whitespace that the input starts with, and this applies it.

                                                            Instances For

                                                              Parses an item of a list in the given style. The saved position is the first item marker's, which every marker lines up with.

                                                              Parses an item from a description list. The saved position is the first item's colon, which every item's colon lines up with.

                                                              Parses a block quote.

                                                              Parses an unordered list.

                                                              Parses an ordered list.

                                                              Parses a definition list.

                                                              Parses a paragraph (that is, a sequence of otherwise-undecorated inlines). A paragraph contains something other than whitespace, so a run of empty lines is not a paragraph.

                                                              Instances For

                                                                Parses a header.

                                                                Instances For

                                                                  Parses a code block. Each line's token records the fence's indentation on the line after it as trailing whitespace, so the code the block denotes is what the lines' tokens contain.

                                                                  Instances For

                                                                    Parses a directive.

                                                                    Parses a block command.

                                                                    Instances For

                                                                      Parses a link reference target.

                                                                      Instances For

                                                                        Parses a footnote reference target.

                                                                        Instances For

                                                                          Parses a block.

                                                                          When recordTrailing is set, the block's final token consumes the whitespace that follows the block (including the indentation of the next line), even when error recovery lost the token that would have consumed it.

                                                                          Parses zero or more blocks. Each block's final token consumes the whitespace that follows it, the next line's indentation included, and blockSepFallback parses the whitespace after a block whose final token was lost to error recovery.

                                                                          Parses one or more blocks.

                                                                          Parses a document: the whitespace it starts with, then zero or more blocks.

                                                                          The document's first token records the whitespace between the position where this parser starts and that token. A caller that starts it part-way into a larger input is responsible for the whitespace before that position, which a doc comment's opening delimiter records as its trailing whitespace.

                                                                          Instances For

                                                                            Returns the start and end of the range over which a Verso parse error at pos is reported, along with the error to report. An end position of none indicates that the error has no range, but is to be reported at a single point.

                                                                            An error that includes an unexpected token is reported at that token's range. When such an error has no message of its own, as with errors from Lean's own parsers, a message is derived from the token.

                                                                            Otherwise, the range starts at pos and covers the character there, or the whole run of it when a Verso element repeats that character to make a single delimiter (e.g. *** for bold text). At the end of the input, and at a newline, the end is none.

                                                                            Whitespace before the error stays outside the range.

                                                                            Instances For

                                                                              The syntax kinds of the nodes that documentFn produces.

                                                                              Instances For

                                                                                Parser information for Verso markup.

                                                                                Listing the syntax kinds that documentFn produces ensures that we don't get spurious module dependencies.

                                                                                Instances For

                                                                                  Parses as ifVerso if the option doc.verso is true, or as ifNotVerso otherwise.

                                                                                  Instances For

                                                                                    Parses as ifVerso if the option doc.verso is true, or as ifNotVerso otherwise.

                                                                                    Instances For

                                                                                      Formatter for ifVerso—formats according to the underlying formatters.

                                                                                      Instances For

                                                                                        Parenthesizer for ifVerso—parenthesizes according to the underlying parenthesizers.

                                                                                        Instances For

                                                                                          Parses as ifVerso if module docs should use Verso syntax, or as ifNotVerso otherwise. Checks doc.verso.module if explicitly set, otherwise falls back to doc.verso.

                                                                                          Instances For

                                                                                            Parses as ifVerso if module docs should use Verso syntax, or as ifNotVerso otherwise. Checks doc.verso.module if explicitly set, otherwise falls back to doc.verso.

                                                                                            Instances For

                                                                                              Formatter for ifVersoModuleDocs—formats according to the underlying formatters.

                                                                                              Instances For

                                                                                                Parenthesizer for ifVersoModuleDocs—parenthesizes according to the underlying parenthesizers.

                                                                                                Instances For

                                                                                                  Disables the option doc.verso while running a parser.

                                                                                                  Instances For

                                                                                                    Formatter for withoutVersoSyntax—formats according to the underlying formatter.

                                                                                                    Instances For

                                                                                                      Parenthesizer for withoutVersoSyntax—parenthesizes according to the underlying parenthesizer.

                                                                                                      Instances For