我想在一个解释性文档中,引用一个Python类的文档,稍后再引用它的构造函数。假设有一个文件
# MyLib/MyClass.py
class MyClass:
"""Class Introduction"""
def __init__(paramX):
""":param paramX: Xes out things"""
还有我的rst文件
#MyLib/docs/source/MyDoc.rst
Some text where :ref:`here` is my reference to "Class Introduction"
and :ref:`there` follows my reference to the __init__ method documentation
如何使引用正常工作:Sphinx文件中需要如何和在何处包含Python文件,以及如何定义(在Python文件中)和解析(在rst文件中)引用?预期输出如下所示:
Some text where <link to documentation of class _MyClass_>...
and
'class MyClass
def __init__(paramX):
paramX: Xes out things'
如前所述,括号<&燃气轮机;包括指向文档的链接,文档本身出现在rst文件中分别由:ref:`here`
和:ref:`there`
引用的“和”之后
根据问题中的示例,模块
ref_constructor.py
使用reST文件
ref_constructor.rst
注意选择适当的角色,在本例中是:class:
和:meth:
您可以根据上下文使用完全限定名或缩写形式编写交叉引用
结果
相关问题 更多 >
编程相关推荐