Python Sphinx中的Autodoc单模块属性

Python Sphinx中的Autodoc单模块属性,python,python-sphinx,autodoc,docutils,Python,Python Sphinx,Autodoc,Docutils,假设我在Python模块中记录了一个变量,如下所示: some_random_name = 'whatever' """The random whatever variable""" 我是否可以在.rst文件中包含该单个变量的autodocs,而不必同时拖动模块\uuuuu doc\uuuu字符串并为其生成文档输出 我试过了 .. automodule: themodule :members: some_random_name 但这两种情况都会拖入\uuuu doc\uuuu字符串,并

假设我在Python模块中记录了一个变量,如下所示:

some_random_name = 'whatever'
"""The random whatever variable"""
我是否可以在.rst文件中包含该单个变量的autodocs,而不必同时拖动模块
\uuuuu doc\uuuu
字符串并为其生成文档输出

我试过了

.. automodule: themodule
   :members: some_random_name

但这两种情况都会拖入
\uuuu doc\uuuu
字符串,并且不会显示
某些随机名称的autodocs
我无法重现记录模块属性的问题。它对我有用。您的模块中是否有一个
\uuuuuuuuuuuuuuuuuuuuuuuu
变量,其值不包括
一些随机名称
?当寻找成员时

可以通过截取事件来删除模块docstring。下面是一个演示(将代码添加到conf.py):

我用另一种方法解决了这个问题(完全解决,与此问题无关),但稍后将检查您的解决方案。
import inspect

def remove_mod_docstring(app, what, name, obj, options, lines):
    """Erase module docstring in-place"""  
    if inspect.ismodule(obj):
        for i in xrange(len(lines)):
            lines[i] = ''

def setup(app):
    app.connect('autodoc-process-docstring', remove_mod_docstring)