在autodoc中排除模块docstring

时间:2013-07-29 15:13:50

标签: python python-sphinx

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

原因是我使用模块docstring来指定命令行选项(使用可爱的docopt)。

1 个答案:

答案 0 :(得分:3)

将以下内容添加到 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模块中的模块docstring。

相关问题