Theo sphinx documentation, chỉ thị .. autoattribute
sẽ có thể ghi lại các thuộc tính cá thể. Tuy nhiên, nếu tôi làm ::autoclass và các thuộc tính dụ
.. currentmodule:: xml.etree.ElementTree
.. autoclass:: ElementTree
.. autoattribute:: ElementTree._root
Sau đó, khi xây dựng tôi nhận được một 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
mặc dù nếu tôi nhanh chóng ElementTree
và cố gắng và truy cập các thuộc tính _root
, nó hoạt động tốt ::
>>> from xml.etree.ElementTree import ElementTree
>>> e = ElementTree()
>>> hasattr(e, '_root')
True
Tôi đang làm gì sai?
(Tôi đang thực sự có vấn đề này với một trong các lớp học của riêng tôi, nhưng tôi chỉ sử dụng lớp ElementTree làm ví dụ vì nó trong thư viện chuẩn)
Đã xác nhận cho tôi. Bất kỳ ý tưởng nếu điều này đã được cố định và nếu có, phiên bản nào? – Rafe
@Rafe: Lỗi vẫn chưa được giải quyết. – mzjn