最佳答案
我使用 狮身人面像 autodoc
特性基于 Python 库的 docstring 生成文档。
交叉引用的语法可以找到 给你
为了允许从文档的其他区域引用该节,该节前必须有一个标签。
我有一个. rst (RestructeredText)文件,用于我的一个类
.. autoclass:: classname
:members:
为类生成文档。
我的问题是,如何从另一个类引用自动生成的方法。第一份文件?如果我试图在方法的 docstring 中放置一个标签,Sphinx 会抱怨。如果我试图在方法标题之前放置一个标签,Sphinx 不能识别它。
有没有一种简单的方法可以做到这一点,或者我必须在类文件中显式地写入方法名,并在方法名前面加上一个标签?
下面是一个示例,在[ Python document entation2中的引用正在做我需要做的事情(我假设它使用了 autodoc 特性,尽管我不确定)