我有一个utils
我的包中的模块。它由多个不需要实例化的杂项独立方法组成。
我想在其中放置一些通用注释/文档字符串utils
文件,例如:
import os
import json
"""
Miscellaneous methods that help in <<blah blah>>
Does not require explicit instantiation.
The following actions can be performed:
=============== ===============
Action Method
=============== ===============
Get a :meth:`methoda`
Get b :meth:`methodb`
"""
def methoda(data):
"Gets A ..."
...
def methodb(data):
"Gets B ..."
...
如上所示,文档字符串有一个表,其中包含各个方法的链接。目前,我的index.rst
有这部分要包括utils
:
Utilities
============
.. automodule:: packagename.utils
:members:
目前,我在文档中正确显示了各个方法的文档字符串,但没有模块的顶级文档字符串(在任何类或方法之外)。让 sphinx 包含上述内容的最佳方法是什么?
一种选择可能是将顶级文档字符串移到该文件之外,例如index.rst
等等。但我宁愿不这样做,并将其保留在源文件中。
感谢 jonsharpe 的评论,并引导我找到了执行此操作的正确方法。
为了供其他人将来参考,我基本上将文档字符串移动到文件的开头:
"""
Miscellaneous methods that help in <<blah blah>>
Does not require explicit instantiation.
The following actions can be performed:
=============== ===============
Action Method
=============== ===============
Get a :meth:`methoda`
Get b :meth:`methodb`
"""
import os
import json
def methoda(data):
"Gets A ..."
...
def methodb(data):
"Gets B ..."
...
就是这样!一切正常。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)