According to the sphinx documentation, the directive .. autoattributeshould be able to document instance attributes. However, if I do ::
.. currentmodule:: xml.etree.ElementTree
.. autoclass:: ElementTree
.. autoattribute:: ElementTree._root
Then, when I create it, I get the AttributeError attribute:
Traceback (most recent call last):etree.ElementTree.ElementTree
File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/sphinx/ext/autodoc.py", line 326, in import_object
obj = self.get_attr(obj, part)
File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/sphinx/ext/autodoc.py", line 232, in get_attr
return safe_getattr(obj, name, *defargs)
File "/Volumes/Raptor/Library/Python/2.7/lib/python/site-packages/sphinx/util/inspect.py", line 70, in safe_getattr
raise AttributeError(name)
AttributeError: _root
although if I create an instance ElementTreeand try to access the attribute _root, it works fine:
>>> from xml.etree.ElementTree import ElementTree
>>> e = ElementTree()
>>> hasattr(e, '_root')
True
What am I doing wrong?
(I have this problem with one of my own classes, but I just use the ElementTree class as an example, as it is in the standard library)
source
share