[parse]¶
Configuration for parsing source documents.
ignore_directives, extend_directives and extend_roles apply to all
parsers. Individual parsers are configured under [parse.parsers.<name>]
(e.g. [parse.parsers.rst], [parse.parsers.md]).
With no parsers configured, documents are parsed as reStructuredText. Once
any parser is configured, the listed parsers are the complete set and file
discovery is derived from their include globs — so a lone
[parse.parsers.md] parses Markdown only.
Guide: Parsing.
- parse.autosectionlabel_maxdepth¶
- Type:
- integer
- Default:
0
How deep automatic section labels are generated.
Unset or
0means no limit: every section gets a label. Set toNto label only the topNsection levels of each document (1= every top-level section). Active only whensphinx.ext.autosectionlabelis listed in[parse].extensions.Equivalent to Sphinx’s
autosectionlabel_maxdepthconfiguration value, and shares its default (unlimited).
- parse.autosectionlabel_prefix_document¶
- Type:
- boolean
- Default:
false
Whether automatic section labels are prefixed with the document name.
Off by default, matching Sphinx: a section is referenced by its bare title, e.g.
:ref:`Section Title`. When on, labels become:ref:`doc/path:Section Title`— recommended, since bare titles easily collide across documents. Active only whensphinx.ext.autosectionlabelis listed in[parse].extensions.Equivalent to Sphinx’s
autosectionlabel_prefix_documentconfiguration value, and shares its default.
- parse.default_role¶
- Type:
- string
- Default:
""
The role applied to bare interpreted text (
`text`).Unset or an empty string means the docutils default,
title-reference. An in-document.. default-role::directive overrides this from its point onward; a bare.. default-role::reset returns totitle-reference, not to this value.Equivalent to Sphinx’s
default_roleconfiguration value.
- parse.extend_directives¶
- Type:
- table of tables
- Default:
{}
A map of directive names to extend the directives with.
Each entry: Configuration to define parsing rules for a single directive.
- parse.extend_directives.<name>.argument¶
- Type:
- boolean
- Default:
false
If True, the directive accepts an argument.
- parse.extend_directives.<name>.content¶
- Type:
- boolean
- Default:
false
If True, the directive accepts content.
- parse.extend_directives.<name>.content_required¶
- Type:
- boolean
- Default:
false
If True, a warning will be logged if the directive contains no content.
- parse.extend_directives.<name>.description¶
- Type:
- string
- Default:
""
A short, human readable description of the directive.
- parse.extend_directives.<name>.extension¶
- Type:
- string
- Default:
""
The extension that provides the directive, if any.
- parse.extend_directives.<name>.named_options¶
- Type:
- table of tables
- Default:
{}
A map of named options to specifications.
Each entry: Configuration to define a single directive option.
- parse.extend_directives.<name>.named_options.<name>.choices¶
- Type:
- array of strings
A list of valid choices for the option.
- parse.extend_directives.<name>.named_options.<name>.description¶
- Type:
- string
- Default:
""
A short, human readable description of the option.
- parse.extend_directives.<name>.named_options.<name>.flag¶
- Type:
- boolean
- Default:
false
If True, the option is a flag, i.e. it has no value.
- parse.extend_directives.<name>.options¶
- Type:
- boolean
- Default:
false
If True, the directive accepts options.
- parse.extend_directives.<name>.parse_content¶
- Type:
- boolean
- Default:
false
If True, the directive content is parsed.
- parse.extend_roles¶
- Type:
- table of tables
- Default:
{}
A map of role names to extend the roles with.
Each entry: Configuration to define a single role.
- parse.extend_roles.<name>.description¶
- Type:
- string
- Default:
""
A short, human readable description of the role.
- parse.extend_roles.<name>.extension¶
- Type:
- string
The extension that provides the role, if any.
- parse.extensions¶
- Type:
- array of strings or table of (boolean or table)
- Default:
{}
Built-in Sphinx-extension ports to switch on or off, by extension name.
Each entry overrides one port’s default, and a list entry means exactly the same as
name = true:[parse] extensions = ["sphinx.ext.autosectionlabel"] # or, to switch ports off as well as on: [parse.extensions] "sphinx.ext.autosectionlabel" = true "sphinxcontrib.video" = { active = false }
Markup ports are on by default, so their markup renders without being listed:
sphinxcontrib.video,sphinx_syntax_example,sphinx.ext.todo,sphinx_design,sphinxcontrib.mermaidandsphinxcontrib.plantuml.sphinx.ext.autosectionlabelis off by default because it changes resolution project-wide (a:ref:target per section title) with no markup opting in, andsphinx.ext.extlinksactivates on its own data — a populated[parse.extlinks]table switches it on.Switching off a port that gates DIRECTIVES does not make its markup unknown: it still parses, its options are still validated and completed, and each use site renders as a labelled placeholder showing its source and warns (
directive.extension_disabled) naming the extension and this key.The two ports that gate something else are quieter, and neither can warn per use site:
sphinx.ext.extlinksgates ROLES whose names come from your own[parse.extlinks]table, so switched off they fall back to a plain chip carrying the role name and its text, with no warning; andsphinx.ext.autosectionlabelhas no markup at all, so switching it off simply stops the labels existing.activeis the only field an entry table may carry; an entry table without it (including an empty one) switches the port on, and any other key is reported as unknown (config.unknown_extension_option) and ignored.sphinx_test_reportscarries configuration of its own, in the[test_reports]section, which switches it on by itself (an empty section means the defaults). Listing it here is the same as writing an empty section when there is none;falseswitches it off and keeps the section’s settings, including a section inherited throughextend, and an explicitfalseunder either of its two names beats an explicittrueunder the other. Switched off, its need types and fields are not added and its directives render as labelled placeholders, unless a need type — or a[parse.extend_directives]entry — of the same name owns them (config.test_reports_switched_offsays so once). Its old name,sphinxcontrib.test_reports, is read assphinx_test_reports(config.extension_renamed).Names ubcode ships no port for are ignored, so a
conf.pyextensions list can be mirrored wholesale. Three answers are given rather than silence: a name close to a known port’s is reported as a likely typo (config.unknown_extension);sphinx_needsis built in and cannot be switched off (config.extension_always_on); and a name ubcode knows but ships no port for, such assphinx.ext.autodoc, is reported when switched on (config.extension_unsupported) because only Sphinx can run it.If you also build with
sphinx-build, list the extensions you use explicitly: the defaults here are a ubcode-side courtesy, and Sphinx needs each extension named in its ownextensionslist.Forms:
an array of strings: Extension names whose ports are switched on.
a table of (boolean or table): Extension names mapped to their port setting.
Forms:
a boolean: Switch the port on (
true) or off (false).a table: Switch the port on or off through an entry table.
- parse.extensions.<name>.active¶
- Type:
- boolean
Whether the port is active. Omitted in an entry table means active.
- parse.extlinks¶
- Type:
- table of tables
- Default:
{}
extlinkslink-shorthand roles, each mapping a role name to a URL template and an optional caption.Writing this table is all it takes: a populated
[parse.extlinks]activates thesphinx.ext.extlinksport by itself, so the role names become usable without also naming the extension in[parse].extensions.In each entry
%sis replaced by the role’s text: e.g.[parse.extlinks.issue]withurl = "https://github.com/o/r/issues/%s"makes the roleissuewith text123a link to.../issues/123. A literal percent is written%%, and each string may hold at most one%s(a template with more is reported and the role is skipped).To keep the table but switch the roles off, set
"sphinx.ext.extlinks" = falsein[parse.extensions]: an explicitfalseis a kill switch that wins over the table, and the role names then stay unknown.Each entry: A single
extlinkslink-shorthand role (Sphinxsphinx.ext.extlinks).
- parse.extlinks.<name>.caption¶
- Type:
- string
The link-text template.
%sis replaced by the role’s text (a literal percent is written%%; at most one%s). When unset the link text is the fully expanded URL.
- parse.extlinks.<name>.url¶
- Type:
- string
- Default:
""
The URL template.
%sis replaced by the role’s text; a literal percent is written%%. At most one%sis allowed.
- parse.highlight_language¶
- Type:
- string
- Default:
""
The highlight language applied to literal and code blocks that have no language of their own.
Unset or an empty string means such blocks get no language class. An in-document
.. highlight::directive overrides this from its point onward.Equivalent to Sphinx’s
highlight_languageconfiguration value (though ubCode does not default it to Sphinx’sdefault).
- parse.id_style¶
- Type:
- string
- Default:
"github"
How HTML ids and
#link anchors are made from section titles and names."github"(the default) follows GitHub’s heading anchors: lowercase; letters of any script, digits,_and-are kept; each space becomes-; other punctuation is removed; and a repeated anchor on one page gets-1,-2, …. SoNeeds_Types 2.0anchors at#needs_types-20, and a link written for GitHub or for MyST-Parser’s heading anchors reaches the same heading for a plain-text heading on a page where nothing else claims its slug; the differences page lists the exceptions."docutils"makes Sphinx’s anchors: ASCII only, soNeeds_Types 2.0anchors at#needs-types-2-0, a title with nothing left once accents and compatibility forms are folded to ASCII (日本語,Привет) getsid1, and a repeated heading getsid1,id2, …. Set it when a Sphinx build of the same sources must produce the same anchors, or to keep existing deep links and bookmarks into your site working.Either way, glossary terms keep their
term-prefix and object descriptions (such asconfval) keep Sphinx’s own anchors.Values:
"github": GitHub’s heading-anchor convention (the default)."docutils": Sphinx’s anchors (docutils’make_id), to keep a Sphinx build’s anchors and existing deep links.
- parse.ignore_directives¶
- Type:
- array of strings
- Default:
[]
A set of directive names that will not emit a warning if they are unknown.
- parse.parsers¶
- Type:
- table of tables
- Default:
{}
Per-parser configuration, keyed by parser name (e.g.
rst,md).The parser type is inferred from the canonical keys
rstandmd; give any other key an explicittype. Each parser’sincludeglobs select which files it handles.Each entry: Configuration for a single parser, defined under
[parse.parsers.<name>].Fields not relevant to the inferred parser type are ignored (e.g.
flavourandextensionsonly apply to Markdown parsers).
- parse.parsers.<name>.all_links_external¶
- Type:
- boolean
Treat every link in a Markdown document as an external URL, turning cross-referencing off (Markdown parsers only).
With this on, no destination is looked up:
[](#target),[](other.md),<project:…>,<path:…>and<inv:…>alike keep the URL exactly as written,url_schemestemplates are not applied, and nothing is reported as an unresolved reference. Unset meansfalse— destinations are cross-referenced as documented above.
- parse.parsers.<name>.extensions¶
- Type:
- array of strings or table of (boolean or table of (boolean or integer or string))
- Default:
{}
Per-extension configuration (Markdown parsers only).
Forms:
an array of strings: Extension names to enable with default options.
a table of (boolean or table of (boolean or integer or string)): Extension names mapped to their settings.
Each entry: The setting for a single extension within a
[parse.parsers.md.extensions]table.An extension may be given either a bare boolean (
deflist = true) to enable or disable it with default options, or a sub-table of per-extension options (dollarmath = { allow_space = true }), which also enables it.Forms:
a boolean: Enable (
true) or disable (false) the extension with default options.a table of (boolean or integer or string): Enable the extension with the given per-extension options.
- parse.parsers.<name>.flavour¶
- Type:
- string
The Markdown flavour (Markdown parsers only).
Values:
"commonmark": Plain CommonMark with no extensions enabled by default."myst": MyST Markdown — enables directive/role syntax, front matter, and tables (the always-onMySTcore). MatchingMyST-Parser, no optional extensions are enabled by default; enable them explicitly via the parser’sextensionssetting."gfm": GitHub Flavored Markdown — enables the GFM extension set by default.
- parse.parsers.<name>.footnote_sort¶
- Type:
- boolean
Collect footnote definitions to the foot of the page and sort them (Markdown parsers only).
With this on, every footnote definition the page itself wrote is moved to the foot of the page (below the last section, when there is one) into one list, ordered by its rendered number, and auto footnotes are numbered by the order their references appear rather than the order they are defined. A definition inside an extracted or imported card stays in the card. Turning it off does BOTH: definitions render where they are written, auto footnotes are numbered in definition order, and no rule is written even with
footnote_transitionon. Inert on a flavour with no footnote syntax (commonmark). Unset meanstrue.
- parse.parsers.<name>.footnote_transition¶
- Type:
- boolean
Write a horizontal rule above the collected footnotes (Markdown parsers only).
The rule is
<hr class="footnotes" />, written directly above the collected footnote list. It is omitted on a page whose every top-level block is a footnote definition, and — becausefootnote_sort = falsealso disables the collection — whenever that key is off. Inert on a flavour with no footnote syntax (commonmark). Unset meanstrue.
- parse.parsers.<name>.include¶
- Type:
- array of strings
Glob patterns selecting which discovered files this parser handles.
Defaults to the parser type’s default (
["*.rst"]for RST,["*.md"]for Markdown) when unset.
- parse.parsers.<name>.links_external_new_tab¶
- Type:
- boolean
Open external links in a new browser tab (
mystflavour only).A link that renders as an external URL — a plain web link, an unrecognised-scheme autolink, or a destination a
url_schemesentry rewrote — gainstarget="_blank"andrel="noreferrer noopener". Cross-references, downloads and inventory-resolved links stay in the same tab. Unset meansfalse.
- parse.parsers.<name>.priority¶
- Type:
- integer
Routing priority, used to break ties when a file matches more than one parser equally specifically. Higher wins; defaults to
0.
- parse.parsers.<name>.type¶
- Type:
- string
Explicit parser type, overriding inference from the sub-table key name.
Values:
"rst": The reStructuredText parser."md": The Markdown parser.
- parse.parsers.<name>.url_schemes¶
- Type:
- array of strings or table of (string or table)
- Default:
{}
Custom URL schemes a link destination may carry (Markdown parsers only).
A destination whose scheme is listed here is an external link, rewritten by the entry’s
urltemplate if it has one.http,https,mailtoandftpare always recognised, so declaring one scheme does not un-recognise those:[parse.parsers.md] url_schemes = ["doi"] # recognise, rewrite nothing # …or, to rewrite as well as recognise: [parse.parsers.md.url_schemes] doi = "https://doi.org/{{path}}" gh = { url = "https://github.com/{{path}}", title = "GitHub: {{path}}" }
inv,pathandprojectare reserved for cross-referencing and cannot be redefined here; an entry naming one is reported and ignored.Forms:
an array of strings: Scheme names recognised as external links, with no rewriting.
a table of (string or table): Scheme names mapped to what a destination carrying them becomes.
Forms:
a string: A URL template the destination is rewritten to.
a table: What a link destination carrying one custom URL scheme becomes: the URL to rewrite it to, the text to give it when the author wrote none, and any extra HTML classes. Every key is optional, and an empty table simply recognises the scheme as an external link.
- parse.parsers.<name>.url_schemes.<name>.classes¶
- Type:
- array of strings
Extra HTML classes to add to the rendered link, after any the author attached to it inline.
- parse.parsers.<name>.url_schemes.<name>.title¶
- Type:
- string
The link text to use when the author wrote none — an autolink (
<wiki:Rust>) or an empty label ([](wiki:Rust)). A link with its own text keeps that text. Substitutes the same variablesurldoes.
- parse.parsers.<name>.url_schemes.<name>.url¶
- Type:
- string
The URL template the destination is rewritten to. Unset leaves the destination untouched, so an entry can annotate without rewriting.
A template may substitute any of the seven parts of the destination:
{{uri}}(the whole destination, scheme included),{{scheme}},{{netloc}},{{path}},{{params}},{{query}}and{{fragment}}. Surrounding whitespace inside the braces is allowed ({{ path }}). Substitution is plain text replacement, not Jinja: any other{{name}}is left in the result verbatim, and a part the destination does not have substitutes as the empty string (so a template writing#{{fragment}}on a fragment-less destination leaves a bare trailing#).{{params}}is always empty: ubcode never splits a trailing;parameterssegment off the path, so{{path}}keeps it.
- parse.raw_enabled¶
- Type:
- boolean
- Default:
true
Whether the
rawdirective passes its content through to the output.On by default, matching docutils and Sphinx: a
rawblock’s content reaches the built HTML verbatim, unescaped. Set it tofalsewhen the project builds contributions you do not control — the directive then passes nothing through, warns (directive.raw_disabled), and renders a placeholder showing its own source instead. This applies everywhere a document is processed:ubc build,ubc check, and the editor preview.Gates the
rawDIRECTIVE only — the reStructuredText.. raw::form and itsMySTtwin — exactly like the docutils setting of the same name. HTML written directly in a Markdown document is not a directive and is not affected.
- parse.rst_epilog¶
- Type:
- string
- Default:
""
reStructuredText source appended to every RST document.
Unset or an empty string means nothing is appended. The content is parsed as RST at the very end of each document.
Equivalent to Sphinx’s
rst_epilogconfiguration value.
- parse.rst_prolog¶
- Type:
- string
- Default:
""
reStructuredText source prepended to every RST document.
Unset or an empty string means nothing is prepended. The content is parsed as RST at the very start of each document, so a
.. default-role::or.. role::here applies to the whole document (state flows out of the prologue into the body).Equivalent to Sphinx’s
rst_prologconfiguration value.
- parse.syntax_example_numbering¶
- Type:
- boolean
- Default:
false
Number the
syntax-exampleblocks of each document.Off by default, which titles every block
Example(or its title argument, when given). When on, the blocks of a document are counted1, 2, …and titledExample N, orExample N: <title>when a title argument is given. The count restarts at each document.Active only when
sphinx_syntax_exampleis listed in[parse].extensions; inert otherwise, like the extension’s own directive. Equivalent to thesyntax_example_numberingconfiguration value of thesphinx-syntax-exampleSphinx extension, which requires version 0.2.0 or later of that package — an earlier one ignores the confval, so asphinx-buildagainst it renders unnumbered titles while ubCode renders numbered ones.
- parse.todo_include_todos¶
- Type:
- boolean
- Default:
true
Whether
todoblocks are rendered, andtodolistblocks expanded.On by default: enabling the
sphinx.ext.todoport is normally how a project says it wants its todos visible. Set it tofalseto hide them — atodothen renders nothing at all and atodolistrenders nothing at all, exactly as if the markup were absent, which is how the build reads for an audience that should not see outstanding work.Active only when
sphinx.ext.todois listed in[parse].extensions; until then both directives render as unhandled placeholders and this setting is inert.Equivalent to Sphinx’s
todo_include_todosconfiguration value, whose default isfalse; ubCode defaults it totrueinstead. A project that shares one source tree betweensphinx-buildand ubCode should therefore set both values explicitly rather than relying on either default.
- parse.todo_link_only¶
- Type:
- boolean
- Default:
false
Whether a
todolistentry’s backlink is shown on its own, without the surrounding “is located in<file>, line<n>” sentence.Off by default, which renders the full sentence. Turn it on for a listing that is read on its own, where the file-and-line detail is noise. Active only when
sphinx.ext.todois listed in[parse].extensions.Equivalent to Sphinx’s
todo_link_onlyconfiguration value, and shares its default.