Commits

Takayuki Shimizukawa  committed d2fd45d

Fix autodoc crash if :members: and :special-members: ware both set (by d7ac5e4).

  • Participants
  • Parent commits 4aa18c3

Comments (0)

Files changed (2)

File sphinx/ext/autodoc.py

                         membername != '__doc__':
                     keep = has_doc or self.options.undoc_members
                 elif self.options.special_members and \
+                     self.options.special_members is not ALL and \
                         membername in self.options.special_members:
                     keep = has_doc or self.options.undoc_members
             elif want_all and membername.startswith('_'):

File tests/test_autodoc.py

 
 
 def skip_member(app, what, name, obj, skip, options):
+    if name in ('__special1__', '__special2__'):
+        return skip
     if name.startswith('_'):
         return True
     if name == 'skipmeth':
     should.append(('method', 'test_autodoc.Class.inheritedmeth'))
     assert_processes(should, 'class', 'Class')
 
+    # test special members
+    options.special_members = ['__special1__']
+    should.append(('method', 'test_autodoc.Class.__special1__'))
+    assert_processes(should, 'class', 'Class')
+    options.special_members = ALL
+    should.append(('method', 'test_autodoc.Class.__special2__'))
+    assert_processes(should, 'class', 'Class')
+    options.special_members = False
+
     options.members = []
     # test module flags
     assert_result_contains('.. py:module:: test_autodoc',
         self.inst_attr_string = None
         """a documented instance attribute"""
 
+    def __special1__(self):
+        """documented special method"""
+
+    def __special2__(self):
+        # undocumented special method
+        pass
+
 
 class CustomDict(dict):
     """Docstring."""