Sphinx自动文档-跳过成员处理程序:使用拿破仑时不能显示__init__()
问题描述
我希望将__init__()的文档字符串包括在我的Shinx生成的文档中。
我正在跟随the accepted answer to this stackoverflow question为autodoc-skip-member添加处理程序,但仍然无法查看我的__init__()文档。if name == "__init__":块中的跟踪代码显示我正在访问该代码。
凭直觉,我从extensions定义中删除了'sphinx.ext.napoleon',留下了
extensions = [
'sphinx.ext.autodoc',
# 'sphinx.ext.napoleon',
]
然后我可以看到__init__()文档。
napoleon_include_special_with_doc,它表示默认为True。在conf.py中将其显式设置为True似乎不会改变任何内容。
ETA:如果我添加以下方法:
def __blah__(self):
'''blah blah blah'''
print self.__class__
我在生成的文档中看到__blah__()。
- 如果将
__blah__的名称更改为__repr__或__str__, 我在生成的文档中看到它们。 - 如果我注释掉现有的
__init__并更改__blah__到__init__我看不到。
因此它似乎特定于__init__()。
这是一个已知的问题吗?使用拿破仑时有没有其他方法来控制这个问题?
解决方案
根据Rob在https://github.com/sphinx-doc/sphinx/issues/2374中的说明,如果您使用的任何扩展也设置了"AutoDoc-Skip-Member"事件的处理程序,则只会使用一个处理程序。这似乎是眼下的问题。谢谢Rob!
相关文章