在autodoc中排除模块docstring [英] Exclude module docstring in autodoc

查看:89
本文介绍了在autodoc中排除模块docstring的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to use autodoc in Sphinx to print out the docstrings of every functions in a specific module but exclude the module's docstring. Is it possible?

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

The reason is that I'm using the modules docstring to specify command line options (with the lovely docopt).

推荐答案

将以下内容添加到 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 事件。

这篇关于在autodoc中排除模块docstring的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆