Skip to content

sphinx-api-relink 0.0.1

Compare
Choose a tag to compare
@github-actions github-actions released this 03 Dec 17:19
· 23 commits to main since this release

First release: the docs/_relink_references.py scripts are now available as a Sphinx extension πŸŽ‰

Installation

Just install through PyPI with pip:

pip install sphinx-api-relink

Next, in your Sphinx configuration file (conf.py), add "sphinx_api_relink" to your extensions:

extensions = [
    "sphinx_api_relink",
]

Usage

There are two ways to relink type hint references in your API. The first one, api_target_substitutions, should be used when the target is different than the type hint itself:

api_target_substitutions: dict[str, str | tuple[str, str]] = {
    "sp.Expr": "sympy.core.expr.Expr",
    "Protocol": ("obj", "typing.Protocol"),
}

The second, api_target_types, is useful when you want to redirect the reference type. This is for instance useful when Sphinx thinks the reference is a class, but it should be an obj:

api_target_types: dict[str, str] = {
    "RangeDefinition": "obj",
}