python - 属性的 Sphinx 值报告为无

标签 python python-sphinx autodoc

当我使用 Sphinx autodoc 来记录一个类时,总是会报告属性的值(正如它所说的那样 here,在 #437 下)但总是“= None”

Attribute = None
    Some Documentation

我把它包括在内

.. autoclass:: core.SomeClass
   :members:

我的代码看起来像

class SomeClass(object):
    def __init__(self):
        self.attribute = "value" #: Some Documentation

有没有办法让“= None”报告真实值,或者让它消失?

最佳答案

会有一个:annotation:即将推出的 sphinx 1.2 版(以及第二个测试版)中的选项(请参阅 pull-request)。

对于 autodata/autoattribute然后你可以强制一个特定的值或抑制它。 因此,为了不打印属性的值,您将放置:

.. autoclass:: core.SomeClass

   .. autoattribute:: attribute
      :annotation:

目前它只适用于 autodata/autoattribute直接而不是递归地使用 automodule/autoclass .

关于python - 属性的 Sphinx 值报告为无,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9153473/

相关文章:

python - 使用带有自制软件的 python 安装 selenium

python - 在 Sphinx 中创建 LaTeX 数学宏

python - Sphinx 找不到我的 python 文件。说 'no module named ...'

python - 如何将 Sphinx 的 Autodoc 扩展用于私有(private)方法?

Python3逐行读取混合文本/二进制数据

python - Django 映射到 Postgres citext 数组返回一个 str 而不是一个列表

python - Python中最有效的字符串连接方法是什么?

python - 使用 Sphinx 生成 S5 演示文稿

python - 在Python Sphinx中,有没有办法隐藏autodoc设置代码?

python - sphinx-apidoc 获取子模块,但 autodoc 没有记录它们