Consider the basic Sphinx RST file
.. automodule:: test.submod
:members:
.. automodule:: test.submod2
:members:
with the following in conf.py
:
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
extensions = [
'sphinx.ext.autodoc'
]
nitpicky = True
And a basic module test
with
# test/__init__.py
from .submod import func
from .submod2 import func2
# test/submod.py
def func():
"""
func docstring
"""
# test/submod2.py
def func2():
"""
func2 docstring
See also :func:`func`
"""
When I build this, I get the warning
/home/aaronmeurer/Documents/sphinx-test/test/submod2.py:docstring of test.submod2.func2:3: WARNING: py:func reference target not found: func
And if I check the built HTML, the func
link does not actually link to the func
docstring.
I tried adding
.. currentmodule:: test
to the top of the index.rst
(see https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#directive-py:currentmodule), but that doesn't work.
I'd like to be able to cross reference func
without writing out the fully qualified name test.submod.func
whenever I link to it (and I'd also prefer if it doesn't show as a fully qualified name in the final HTML).