Documentation

Mathlib.Util.VersoRoles

Verso docstring roles #

This module provides custom Verso docstring roles and code blocks used to support Verso syntax in Mathlib docstrings:

The roles are declared in the root namespace so that they are available in every docstring without opening a namespace.

A reference to a bibliography entry in docs/references.bib.

  • key : String

    The citation key, as it appears in docs/references.bib.

Instances For
    @[instance_reducible]
    Equations

    A verbatim code listing together with the name of its language.

    • language : String

      The language of the code listing.

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

        Extracts the single code literal from the contents of a role, such as the `x` in {role}`x`.

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

          Whether bib (the contents of docs/references.bib) contains an entry with the given key.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            def url (xs : Lean.TSyntaxArray `Lean.Doc.Parser.inline) :

            A link to a URL.

            The code literal contains the target, which is also used as the link text, as in {url}`https://leanprover.org`.

            Equations
            Instances For

              If doc.verso.libraryNote.warnOnMissing is enabled, a {library_note} reference that is not in scope generates a warning.

              A reference to a library note.

              The code literal contains the note's label, as in {library_note}`partially-applied ext lemmas`. A warning is reported when no library note with this label is in scope, so that references to notes defined later are allowed. Set the option doc.verso.libraryNote.warnOnMissing to false to disable this warning.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def cite (key : Lean.StrLit) (xs : Lean.TSyntaxArray `Lean.Doc.Parser.inline) :

                A reference to a bibliography entry.

                The positional argument is the entry's key in docs/references.bib, and the bracketed content is the text to render, as in {cite "Adamek_Rosicky_1994"}[Adámek–Rosický]. A warning is emitted when the key is not found in docs/references.bib.

                TODO: this performs an O(n) lookup of bibliographic entries for every reference appearing in each docstring. For potential optimization, see: https://github.com/leanprover-community/mathlib4/pull/44135/changes#r4258754031

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

                  A verbatim code listing in the language named by the positional argument, as in ```code python.

                  The language is recorded for later use; the listing itself is rendered verbatim.

                  Equations
                  Instances For