Consider the following function:
from pathlib import Path
from typing import Union
def func(path: Union[str, Path]) -> None:
"""My super function.
Parameters
----------
path : str | Path
path to a super file.
"""
pass
When documenting with sphinx, I would like to cross-ref both str
and Path
with intersphinx. But obviously, it does not work for the latter since it is referenced as pathlib.Path
in the objects.inv
file.
Is there a way to tell intersphinx/sphinx that Path
is from the pathlib
module? Without resorting to:
path : str | `pathlib.Path`
or
path : str | `~pathlib.Path`
which does not render nicely in a python interpreter, e.g. IPython.
from x-ref the python standard library with intersphinx while omitting the module name
No comments:
Post a Comment