我有点困惑,为什么我的交叉引用目标是不能正确工作。似乎只有完整的路径才有效。我有以下项目结构:
my_project
-my_project
-adapters
-adapter_base
-adapter_1
-adapter_2
-docs
-build
-source
-config.py
配置
sys.path.insert(0, os.path.abspath('..'))
index.rst
.. toctree::
:maxdepth: 2
modules/the_api
模块.第一个
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:
适配器_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的目标路径,但只有完整的路径有效。你知道为什么其他三个不是吗?
尽管这很尴尬,但解决方案是:meth:
而不是:func:
不知何故,我错过了斯芬克斯有:meth:
指令的事实。。。