Python sphinx 实例属性错误
我正在尝试Python sphinx 实例属性错误,python-sphinx,Python Sphinx,我正在尝试。。自动类::具有实例属性的类: .. autoclass:: synergine.core.Test.Test :members: :undoc-members: :private-members: of(在文件synergine/core/Test.py中): 但是当我makehtmlsphinx时,会出现以下错误: /home/bux/Projets/synergine/doc/source/Components.rst:143: WARNING: autod
。。自动类::
具有实例属性的类:
.. autoclass:: synergine.core.Test.Test
:members:
:undoc-members:
:private-members:
of(在文件synergine/core/Test.py中):
但是当我makehtml
sphinx时,会出现以下错误:
/home/bux/Projets/synergine/doc/source/Components.rst:143: WARNING: autodoc: failed to import attribute 'Test._foo' from module 'synergine.core.Test'; the following exception was raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/sphinx/util/inspect.py", line 108, in safe_getattr
return getattr(obj, name, *defargs)
AttributeError: type object 'Test' has no attribute '_foo'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/sphinx/ext/autodoc.py", line 342, in import_object
obj = self.get_attr(obj, part)
File "/usr/local/lib/python3.4/dist-packages/sphinx/ext/autodoc.py", line 241, in get_attr
return safe_getattr(obj, name, *defargs)
File "/usr/local/lib/python3.4/dist-packages/sphinx/util/inspect.py", line 114, in safe_getattr
raise AttributeError(name)
AttributeError: _foo
为什么??我要做什么来记录这个实例属性
编辑:似乎报告了错误:。有办法破解吗?这个问题仍然存在!
当我想要创建内部开发人员文档时,我遇到了这个问题。
因此,我还希望记录私有保护变量和类常量
例子:
类Foo(对象):
#:foo是。。。
__foo=[]
__巴=无
"""
酒吧店。。。
"""
# [...]
解决方案:
在sphinx.util.inspect
中更改函数safe\u getattr
:
def safe_getattr(对象,名称,*devargs):
“”“将所有异常转换为AttributeError的getattr()。”
尝试:
如果name.startswith(“uuuuu”)而不是name.endswith(“uuuu”):#似乎是错误报告:。有没有破解的方法?有一种“破解”的方法可能会奏效,那就是在测试类的定义中添加\uuuu slots\uuuu=[''ufoo']
(类似于)。你试过我在前面的评论中的建议了吗?还没有,我会在可能的时候尝试,并在这里通知你;)谢谢,我会测试一下,完成后再回来。
/home/bux/Projets/synergine/doc/source/Components.rst:143: WARNING: autodoc: failed to import attribute 'Test._foo' from module 'synergine.core.Test'; the following exception was raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/sphinx/util/inspect.py", line 108, in safe_getattr
return getattr(obj, name, *defargs)
AttributeError: type object 'Test' has no attribute '_foo'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/sphinx/ext/autodoc.py", line 342, in import_object
obj = self.get_attr(obj, part)
File "/usr/local/lib/python3.4/dist-packages/sphinx/ext/autodoc.py", line 241, in get_attr
return safe_getattr(obj, name, *defargs)
File "/usr/local/lib/python3.4/dist-packages/sphinx/util/inspect.py", line 114, in safe_getattr
raise AttributeError(name)
AttributeError: _foo