summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2013-01-12 18:12:55 +0900
committershimizukawa <shimizukawa@gmail.com>2013-01-12 18:12:55 +0900
commite17cfb522d2a62321dde3e781098e524d8cf91e2 (patch)
treede8c8fd9a73df6b35fb29cf38942434d92de2679
parent3f309459018bea48cc731d4ca9d5fb9d8fc8e6a0 (diff)
downloadsphinx-e17cfb522d2a62321dde3e781098e524d8cf91e2.tar.gz
fix: autodoc documented descriptor class as attribute
-rw-r--r--sphinx/ext/autodoc.py2
-rw-r--r--tests/test_autodoc.py11
2 files changed, 12 insertions, 1 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py
index 4adf7b69..825c63ff 100644
--- a/sphinx/ext/autodoc.py
+++ b/sphinx/ext/autodoc.py
@@ -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))
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py
index 7a1d6d7f..be6c4ec9 100644
--- a/tests/test_autodoc.py
+++ b/tests/test_autodoc.py
@@ -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."""