问题描述
问题
我使用 sphinx.ext.autosummary
作为我的 python 包。问题是 .. autosummary::
始终添加 .. automethod:: __init__
,即使没有记录。
与此同时,我找到了各种方法将其第三次包含(作为特殊成员)或包含在方法中;但不是我如何摆脱.. automethod:: __init__
。
如图所示,这只是复制了上面的类规范,根本没有用。当然,我可以手动创建所有 *.rst
,但这不是一种选择,并且会使自动汇总有些过时。此外,由于 duplicate object description
(__init__
也在方法中,这很好),它会创建警告。
系统
有没有人知道我几个小时以来一直在寻找的黄金提示? :)
非常感谢!
解决方法
解决方案
在 templates_path
(参见 conf.py
;通常为 "_templates"
)中创建一个文件夹 autosummary
。搜索默认的 class.rst
,将其复制到新文件夹 (_templates/autosummary/class.rst
) 并根据需要调整模板。没有其他要求。
我对class.rst
的调整
- 在
.. autoclass:: {{ objname }}
添加:noindex:
之后。 - 删除了第
.. automethod:: __init__
行。 - 需要弄清楚
:noindex:
作为默认值是否是一个好主意。
非常感谢@mzjn,这是我错过的提示;拯救了我的一天!