5
根據sphinx documentation,.. autoattribute
指令應該能夠記錄實例屬性。但是,如果我當建設做::autoclass和實例屬性
.. currentmodule:: xml.etree.ElementTree
.. autoclass:: ElementTree
.. autoattribute:: ElementTree._root
然後我得到一個AttributeError:
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
即使如果我實例ElementTree
,並嘗試訪問_root
屬性,它工作正常::
>>> from xml.etree.ElementTree import ElementTree
>>> e = ElementTree()
>>> hasattr(e, '_root')
True
我在做什麼錯?
(實際上,我有我自己的一個類這個問題,但我只是用了ElementTree類爲例,因爲它是在標準庫)
也爲我確認。任何想法,如果這是固定的,如果是這樣,什麼版本? – Rafe
@Rafe:錯誤仍然沒有解決。 – mzjn