sphinx_linkfix.extension
Sphinx extension to rewrite internal links in reStructuredText files.
Classes
Transform to rewrite image paths early in the process. |
|
Post-transform to rewrite internal links in reStructuredText files. |
Functions
|
Check if a given href is an external link. |
|
Remove the leading docs folder prefix from a path string. |
|
Set up the Sphinx extension. |
Module Contents
- class sphinx_linkfix.extension.RstImageRewriter(document, startnode=None)[source]
Bases:
sphinx.transforms.SphinxTransformTransform to rewrite image paths early in the process.
- default_priority = 210
Numerical priority of this transform, 0 through 999 (override).
- class sphinx_linkfix.extension.RstLinkRewriter(document, startnode=None)[source]
Bases:
sphinx.transforms.post_transforms.SphinxPostTransformPost-transform to rewrite internal links in reStructuredText files.
- _process_references(docs_relative_path: str, exts: tuple[str, Ellipsis]) int[source]
Process and rewrite reference nodes.
- _sanitize_fragment_for_latex(fragment: str) str[source]
Sanitize a fragment for LaTeX compatibility.
- default_priority = 999
Numerical priority of this transform, 0 through 999 (override).
- sphinx_linkfix.extension._is_external(href: str) bool[source]
Check if a given href is an external link.
- sphinx_linkfix.extension._strip_docs_prefix(path_str: str, docs_relative_path: str) str[source]
Remove the leading docs folder prefix from a path string.
This function handles both relative and absolute paths and normalizes different prefix formats: - Prefix “docs”, “docs/”, “/docs”, “/docs/” all work consistently - For relative paths like “docs/something”, it removes the docs prefix - For absolute paths like “/docs/something”, it removes the docs prefix