fix: autodoc documented descriptor class as attribute

This commit is contained in:
Takayuki Shimizukawa 2013-01-12 18:12:55 +09:00
parent f363ef400e
commit 3a5277c14c
2 changed files with 12 additions and 1 deletions

View File

@ -1191,7 +1191,7 @@ class AttributeDocumenter(ClassLevelDocumenter):
def can_document_member(cls, member, membername, isattr, parent):
isdatadesc = isdescriptor(member) and not \
isinstance(member, cls.method_types) and not \
type(member).__name__ == "method_descriptor"
type(member).__name__ in ("type", "method_descriptor")
return isdatadesc or (not isinstance(parent, ModuleDocumenter)
and not inspect.isroutine(member)
and not isinstance(member, class_types))

View File

@ -581,6 +581,13 @@ def test_generate():
del directive.env.temp_data['autodoc:module']
del directive.env.temp_data['py:module']
# test descriptor class documentation
options.members = ['CustomDataDescriptor']
assert_result_contains('.. py:class:: CustomDataDescriptor(doc)',
'module', 'test_autodoc')
assert_result_contains(' .. py:method:: CustomDataDescriptor.meth()',
'module', 'test_autodoc')
# --- generate fodder ------------
__all__ = ['Class']
@ -605,6 +612,10 @@ class CustomDataDescriptor(object):
return self
return 42
def meth(self):
"""Function."""
return "The Answer"
def _funky_classmethod(name, b, c, d, docstring=None):
"""Generates a classmethod for a class from a template by filling out
some arguments."""