【发布时间】:2023-03-14 00:12:01
【问题描述】:
我有点困惑,为什么我的交叉引用目标无法正常工作。只有完整路径似乎有效。我有以下项目结构:
my_project
-my_project
-adapters
-adapter_base
-adapter_1
-adapter_2
-docs
-build
-source
-config.py
config.py
sys.path.insert(0, os.path.abspath('..'))
index.rst
.. toctree::
:maxdepth: 2
modules/the_api
modules.rst
Adapter Base
------------
.. automodule:: my_project.adapters.base
:members:
:inherited-members:
:show-inheritance:
Adapter 1
---------
.. automodule:: my_project.adapters.adapter_1
:members:
:inherited-members:
:show-inheritance:
adapter_1.py
class Adapter1(object):
pass
class Adapter1API(object):
def method_a(self):
"""the docs for this method_b"""
pass
def method_b(self):
"""the docs for this method
This works :func:`my_project.adapters.adapter_1.method_a`
No link :func:`method_a`
No link :func:`.method_a`
No link :func:`.adapter_1.method_a`
"""
正如您在 method_b 中看到的,我尝试了 4 种方法来创建指向 method_a 的目标路径,并且只有完整路径有效。任何想法为什么其他 3 个不是?
【问题讨论】:
标签: python python-sphinx cross-reference