Commits

Takayuki Shimizukawa  committed aebaf74

fix: autodoc documented descriptor class as attribute

  • Participants
  • Parent commits ba21252

Comments (0)

Files changed (2)

File sphinx/ext/autodoc.py

     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))

File tests/test_autodoc.py

     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']
             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."""