Georg Brandl  committed 373a410

Autodoc can now exclude single members from documentation
via the ``exclude-members`` option.

  • Participants
  • Parent commits 5cc68f7
  • Branches default

Comments (0)

Files changed (4)

   - Autodoc can document classes as functions now if explicitly
     marked with `autofunction`.
+  - Autodoc can now exclude single members from documentation
+    via the ``exclude-members`` option.
   - Autodoc can now order members either alphabetically (like
     previously) or by member type; configurable either with the
     config value ``autodoc_member_order`` or a ``member-order``

File doc/ext/autodoc.rst

      .. versionadded:: 0.6
+  * The directives supporting member documentation also have a
+    ``exclude-members`` option that can be used to exclude single member names
+    from documentation, if all members are to be documented.
+    .. versionadded:: 0.6
    .. note::
       In an :dir:`automodule` directive with the ``members`` option set, only

File sphinx/ext/

         return ALL
     return [x.strip() for x in arg.split(',')]
+def members_set_option(arg):
+    """Used to convert the :members: option to auto directives."""
+    if arg is None:
+        return ALL
+    return set(x.strip() for x in arg.split(','))
 def bool_option(arg):
     """Used to convert flag options to auto directives.  (Instead of
     directives.flag(), which returns None.)"""
         # find out which members are documentable
         members_check_module, members = self.get_object_members(want_all)
+        # remove members given by exclude-members
+        if self.options.exclude_members:
+            members = [(membername, member) for (membername, member) in members
+                       if membername not in self.options.exclude_members]
         # document non-skipped members
         memberdocumenters = []
         for (mname, member, isattr) in self.filter_members(members, want_all):
         'noindex': bool_option, 'inherited-members': bool_option,
         'show-inheritance': bool_option, 'synopsis': identity,
         'platform': identity, 'deprecated': bool_option,
-        'member-order': identity,
+        'member-order': identity, 'exclude-members': members_set_option,
         'members': members_option, 'undoc-members': bool_option,
         'noindex': bool_option, 'inherited-members': bool_option,
         'show-inheritance': bool_option, 'member-order': identity,
+        'exclude-members': members_set_option,

File tests/

         deprecated = False,
         members = [],
         member_order = 'alphabetic',
+        exclude_members = set(),
     directive = Struct(
     assert_processes(should, 'class', 'Class')
     should.extend([('method', 'test_autodoc.Class.meth')])
     options.members = ['meth']
+    options.exclude_members = set(['excludemeth'])
     assert_processes(should, 'class', 'Class')
     should.extend([('attribute', 'test_autodoc.Class.prop'),
                    ('attribute', 'test_autodoc.Class.attr'),
     def skipmeth(self):
         """Method that should be skipped."""
-        pass
+    def excludemeth(self):
+        """Method that should be excluded."""
     # should not be documented
     skipattr = 'foo'