I maintain a Python package that is usually imported with a short standardized nickname, in the manner of import numpy as np
or import pandas as pd
. Let's say it's import foobar as fb
.
I am using sphinx to document it, and in my conf.py
I have 'sphinx.ext.autodoc'
among my extensions
, and default_role = 'py:obj'
. This is a nice setup, because it means that whenever my docstrings or separate .rst
files contain an uncluttered string like
See the `foobar.Thing` class documentation for more details.
or even just
See the `Thing` class documentation for more details.
then the text within backticks automatically gets hyperlinked to the documentation for the foobar.Thing
class. But what's missing is the ability to do this:
See the `fb.Thing` class documentation for more details.
The text fb.Thing
does not get hyperlinked, because sphinx (or sphinx autodoc) does not know that fb
is an alias for the foobar
package. How do I tell it that this is the case?
NB: I know it's possible to do it with <>
notation:
See the `fb.Thing <foobar.Thing>` class documentation for more details.
but the docstrings are designed to be read as plain text as well, so I'm hoping that this can be done without introducing this or other forms of :clutter:`...`
into them, but rather somehow in the conf.py
file or in the .. automodule::
statement.