rename sphinx references
Project description
This Sphinx extension allows you to rename a code reference prior to Intersphinx looking up the name. It exists to fix up some oddities that occur when you combine type hints (sphinx-autodoc-typehints) with Intersphinx references. For some objects defined in C extension modules, the fully-qualified name of the object is not the same as the one which is documented in the project’s objects.inv file.
For example, Pandas and Requests have some objects which are documented under a different name than their fully-qualified module name:
pandas.DataFrame is documented under that name, but when imported, it reports that its fully-qualified name is pandas.core.frame.DataFrame
requests.Request reports that it is requests.models.Request
>>> import pandas
>>> pandas.DataFrame
<class 'pandas.core.frame.DataFrame'>
>>> import requests
>>> requests.Request
<class 'requests.models.Request'>
Since sphinx-autodoc-typehints has to rely on this fully-qualified name, and the fully-qualified name doesn’t match the one in these projects’ documentation, the link won’t resolve. You can read more about the issue here.
Solving the Problem
To resolve this, install this module via pip:
pip install sphinx-reference-rename
Add the extension in your conf.py, and put it before sphinx.ext.intersphinx:
extensions = [
# ...
"sphinx_reference_rename",
"sphinx.ext.intersphinx",
# ...
]
Finally, create a dictionary named sphinx_reference_rename_mapping which maps fully-qualified names to the fixed names. For example, given the examples above:
sphinx_reference_rename_mapping = {
"pandas.core.frame.DataFrame": "pandas.DataFrame",
"requests.models.Request": "requests.Request",
}
Now, your sphinx build should succeed!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sphinx-reference-rename-0.1.0.tar.gz
.
File metadata
- Download URL: sphinx-reference-rename-0.1.0.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4faecb5eee611c2478439bf7dec5eef5e9a11d24f3972ef6c86130da0ba8e26 |
|
MD5 | c141b005f26cac5fb6b2108acac8ed34 |
|
BLAKE2b-256 | d63ddf364aa7a30782a8ee2ee079af93e06a0fb1e13fd5727e006223abfa0967 |
File details
Details for the file sphinx_reference_rename-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: sphinx_reference_rename-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a72542df4973ad0f843bb32227cc4df48d4840e715c2cb0e587a90212536162 |
|
MD5 | 1555e686910d0818a800e51e52885721 |
|
BLAKE2b-256 | fab6cb0eca26ab54069b64ba808d40f78de2f1139104074ad0a94958d51a8d37 |