[英]sphinx autodoc-skip-member handler: can't show __init__() when using napoleon
I want to include the docstrings for __init__()
in my sphinx-generated documentation.我想在我的 sphinx 生成的文档中包含
__init__()
的文档字符串。
I was following the accepted answer to this stackoverflow question to add a handler for autodoc-skip-member
and was still unable to see my __init__()
documentation.我正在按照这个 stackoverflow 问题的公认答案为
autodoc-skip-member
添加一个处理程序, autodoc-skip-member
仍然无法看到我的__init__()
文档。 Trace code inside the if name == "__init__":
block shows I am hitting that code. if name == "__init__":
块中的跟踪代码显示我正在点击该代码。
On a hunch I removed 'sphinx.ext.napoleon'
from my extensions
definition, leaving 'sphinx.ext.napoleon'
直觉,我从extensions
定义中删除了'sphinx.ext.napoleon'
,留下
extensions = [
'sphinx.ext.autodoc',
# 'sphinx.ext.napoleon',
]
and then I can see the __init__()
documentation.然后我可以看到
__init__()
文档。
The only thing I see in the napoleon documentation that seems relevant is napoleon_include_special_with_doc
, which it says defaults to True
.我在拿破仑文档中看到的唯一似乎相关的是
napoleon_include_special_with_doc
,它说默认为True
。 Explicitly setting it to True
in conf.py
doesn't seem to change anything.在
conf.py
其显式设置为True
似乎没有任何改变。
ETA: If I add the following method: ETA:如果我添加以下方法:
def __blah__(self):
'''blah blah blah'''
print self.__class__
I see __blah__()
in my generated documentation.我在生成的文档中看到
__blah__()
。
__blah__
to __repr__
or __str__
, I see them in the generated documentation.__blah__
的名称__blah__
为__repr__
或__str__
,我会在生成的文档中看到它们。__init__
and change __blah__
to __init__
I don't see it.__init__
并将__blah__
更改为__init__
我看不到它。 So it seems specific to __init__()
.所以它似乎特定于
__init__()
。
Is this a known issue, and is there another way to control this when using napoleon?这是一个已知问题,在使用拿破仑时是否有另一种方法来控制这个问题?
Napoleon defers to your autodoc configuration for how you want to handle the __init__
method. Napoleon 遵循您的 autodoc 配置,以了解您希望如何处理
__init__
方法。
Check your autodoc settings in conf.py
.检查你的车博士设置
conf.py
。 In particular, make sure autoclass_content is set to either init
or both
.特别是,确保autoclass_content设置为
init
或both
。
Per Rob's followon at https://github.com/sphinx-doc/sphinx/issues/2374 , if you're using any extension that also sets a handler for the "autodoc-skip-member" event only one of the handlers will be used. Per Rob 在https://github.com/sphinx-doc/sphinx/issues/2374的后续,如果您使用的任何扩展也为“autodoc-skip-member”事件设置处理程序,则只有一个处理程序会被使用。 This would seem to be the issue at hand.
这似乎是手头的问题。 Thanks Rob!
谢谢罗布!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.