sphinx_rustdoc_postprocess¶
Post-process sphinxcontrib-rust RST output via pandoc.
sphinxcontrib-rust dumps rustdoc (markdown) doc-comments verbatim into RST
directive bodies. This extension runs after sphinxcontrib_rust’s
builder-inited handler (priority 600 > default 500), walks the generated
.rst files, extracts the markdown content blocks, and converts them to
proper RST through pandoc -f markdown -t rst.
Submodules¶
Attributes¶
Functions¶
|
Convert a markdown fragment to RST via pandoc. |
|
Convert markdown code fences to RST code-block directives. |
|
Convert markdown tables to RST tables via pandoc. |
|
Convert markdown links to RST. |
|
Convert markdown inline code to RST double-backtick literals. |
|
Convert markdown ATX headings to bold labels. |
|
Walk generated RST files and convert markdown fragments. |
|
Append a toctree snippet to a target RST file. |
|
builder-inited callback: postprocess then inject toctree. |
|
Register the extension with Sphinx. |
Package Contents¶
- sphinx_rustdoc_postprocess.__version_tuple__: VERSION_TUPLE¶
- sphinx_rustdoc_postprocess._log¶
- sphinx_rustdoc_postprocess._FENCE_RE¶
- sphinx_rustdoc_postprocess._TABLE_RE¶
- sphinx_rustdoc_postprocess._HEADING_RE¶
- sphinx_rustdoc_postprocess._INLINE_CODE_RE¶
- sphinx_rustdoc_postprocess._MD_LINK_RE¶
- sphinx_rustdoc_postprocess._INTRADOC_LINK_RE¶
- sphinx_rustdoc_postprocess._pandoc(markdown: str) str¶
Convert a markdown fragment to RST via pandoc.
Parameters¶
- markdownstr
The markdown text to convert.
Returns¶
- str
The converted RST text, or the original markdown if pandoc fails.
- sphinx_rustdoc_postprocess._convert_fences(content: str) str¶
Convert markdown code fences to RST code-block directives.
Parameters¶
- contentstr
RST file content potentially containing indented markdown code fences.
Returns¶
- str
Content with code fences replaced by
.. code-block::directives.
- sphinx_rustdoc_postprocess._convert_tables(content: str) str¶
Convert markdown tables to RST tables via pandoc.
Parameters¶
- contentstr
RST file content potentially containing indented markdown tables.
Returns¶
- str
Content with markdown tables replaced by RST grid tables.
- sphinx_rustdoc_postprocess._convert_links(content: str) str¶
Convert markdown links to RST.
Parameters¶
- contentstr
RST file content potentially containing markdown-style links.
Returns¶
- str
Content with
[text](url)converted to`text <url>`_and rustdoc intra-doc links[`name`]converted to``name``.
- sphinx_rustdoc_postprocess._convert_inline_code(content: str) str¶
Convert markdown inline code to RST double-backtick literals.
Parameters¶
- contentstr
RST file content potentially containing markdown single-backtick code.
Returns¶
- str
Content with single-backtick code converted to double-backtick literals.
- sphinx_rustdoc_postprocess._convert_headings(content: str) str¶
Convert markdown ATX headings to bold labels.
RST section headings cannot appear inside directive bodies, so we convert
## Headingto**Heading**which renders as bold.Parameters¶
- contentstr
RST file content potentially containing markdown ATX headings.
Returns¶
- str
Content with headings replaced by bold text.
- sphinx_rustdoc_postprocess.postprocess_rst_files(app: sphinx.application.Sphinx) None¶
Walk generated RST files and convert markdown fragments.
Scans the directory specified by the
rustdoc_postprocess_rst_dirconfig value (relative toapp.srcdir) for.rstfiles and applies all markdown-to-RST conversions in sequence.Parameters¶
- appSphinx
The Sphinx application instance.
- sphinx_rustdoc_postprocess.inject_rust_toctree(app: sphinx.application.Sphinx) None¶
Append a toctree snippet to a target RST file.
Reads the
rustdoc_postprocess_toctree_targetandrustdoc_postprocess_toctree_rstconfig values. If either is empty, the injection is skipped.Parameters¶
- appSphinx
The Sphinx application instance.
- sphinx_rustdoc_postprocess._on_builder_inited(app: sphinx.application.Sphinx) None¶
builder-inited callback: postprocess then inject toctree.
- sphinx_rustdoc_postprocess.setup(app: sphinx.application.Sphinx) dict¶
Register the extension with Sphinx.
Parameters¶
- appSphinx
The Sphinx application instance.
Returns¶
- dict
Extension metadata with version and parallel safety flags.