9

我正在尝试在 Sphinx 中使用 autodoc 打印出特定模块中每个函数的文档字符串,但不包括模块的文档字符串。可能吗?

原因是我使用模块文档字符串来指定命令行选项(使用可爱的文档)。

4

1 回答 1

8

将以下内容添加到conf.py

def remove_module_docstring(app, what, name, obj, options, lines):
    if what == "module" and name == "yourmodule":
        del lines[:]

def setup(app):
    app.connect("autodoc-process-docstring", remove_module_docstring)

此代码通过为autodoc-process-docstring事件yourmodule提供处理程序来删除模块中的模块文档字符串。

于 2013-08-03T08:44:01.707 回答