我无法让 sphinx 为模块创建汇总表。我已添加sphinx.ext.autosummary
到我的conf.py
文件中,并且正在使用numpydoc
. Sphinx 似乎为类的属性和方法创建了汇总表,但它并没有为包含该类的模块创建汇总表。
我创建了一个最小的工作示例(MWE)来测试它。MWE 项目只有一个__init__.py
and which imports generic_module
. 的内容generic_module
是:
def foo(a, b):
"""
Adds a + b
"""
return(a+b)
def bar(a, b):
"""
Subtracts a + b
"""
return(a-b)
class onetwo(object):
"""
Adds 1 or 2
"""
def __init__(self):
self.whatever = 1
def one(self, a):
"""
Adds one to a
"""
return(a + 1)
def two(self,a):
"""
Adds two o a
"""
return(a + 2)
Sphinx 自动文档foo
、bar
和onetwo
. 它还对onetwo
. 但是,它不会在页面顶部为generic_module
.
我知道我可以添加.. autosummary::
到我的generic_module.rst
文件中,如此处所述。但是,我必须列出模块上的每个功能才能使其正常工作。我认为autosummary
扩展可以为我做到这一点。