1. Benoit Boissinot
  2. tonfa/sphinx

Commits

Georg Brandl  committed 5667410

The ``autodoc_skip_member`` event now also gets to decide
whether to skip members whose name starts with underscores.
Previously, these members were always automatically skipped.
Therefore, if you handle this event, add something like this
to your event handler to restore the old behavior::

if name.startswith('_'):
return True

  • Participants
  • Parent commits 7693d99
  • Branches default

Comments (0)

Files changed (3)

File CHANGES

View file
  • Ignore whitespace
 New features added
 ------------------
 
+* Incompatible changes:
+
+  - The ``autodoc_skip_member`` event now also gets to decide
+    whether to skip members whose name starts with underscores.
+    Previously, these members were always automatically skipped.
+    Therefore, if you handle this event, add something like this
+    to your event handler to restore the old behavior::
+
+       if name.startswith('_'):
+           return True
+
 * Configuration:
 
   - The new ``html_add_permalinks`` config value can be used to

File sphinx/ext/autodoc.py

View file
  • Ignore whitespace
                     all_members = sorted(todoc.__dict__.iteritems())
         else:
             all_members = [(mname, getattr(todoc, mname)) for mname in members]
+
         for (membername, member) in all_members:
-            # ignore members whose name starts with _ by default
             if _all and membername.startswith('_'):
-                continue
-
-            # ignore undocumented members if :undoc-members: is not given
-            doc = getattr(member, '__doc__', None)
-            skip = not self.options.undoc_members and not doc
+                # ignore members whose name starts with _ by default
+                skip = True
+            else:
+                # ignore undocumented members if :undoc-members: is not given
+                doc = getattr(member, '__doc__', None)
+                skip = not self.options.undoc_members and not doc
             # give the user a chance to decide whether this member should be skipped
             if self.env.app:
                 # let extensions preprocess docstrings

File tests/test_autodoc.py

View file
  • Ignore whitespace
     app.builder.env.app = app
     app.connect('autodoc-process-docstring', process_docstring)
     app.connect('autodoc-process-signature', process_signature)
+    app.connect('autodoc-skip-member', skip_member)
 
     options = Struct(
         inherited_members = False,
         return '42', None
 
 
+def skip_member(app, what, name, obj, skip, options):
+    if name.startswith('_'):
+        return True
+    if name == 'skipmeth':
+        return True
+
+
 def test_resolve_name():
     # for modules
     assert gen.resolve_name('module', 'test_autodoc') == \
     def undocmeth(self):
         pass
 
+    def skipmeth(self):
+        """Method that should be skipped."""
+        pass
+
     @property
     def prop(self):
         """Property."""