sphinx-api-relink 0.0.1
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-relinkNext, 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",
}