[Python-checkins] r65698 - in doctools/trunk: CHANGES sphinx/ext/autodoc.py

georg.brandl python-checkins at python.org
Fri Aug 15 21:43:53 CEST 2008


Author: georg.brandl
Date: Fri Aug 15 21:43:52 2008
New Revision: 65698

Log:
Respect __all__ when autodocumenting module members.


Modified:
   doctools/trunk/CHANGES
   doctools/trunk/sphinx/ext/autodoc.py

Modified: doctools/trunk/CHANGES
==============================================================================
--- doctools/trunk/CHANGES	(original)
+++ doctools/trunk/CHANGES	Fri Aug 15 21:43:52 2008
@@ -45,6 +45,8 @@
 * sphinx.doc.autodoc has a new event ``autodoc-process-signature``
   that allows tuning function signature introspection.
 
+* Respect __all__ when autodocumenting module members.
+
 * Glossary entries are now automatically added to the index.
 
 * Added ``exclude_dirnames`` config value that can be used to exclude

Modified: doctools/trunk/sphinx/ext/autodoc.py
==============================================================================
--- doctools/trunk/sphinx/ext/autodoc.py	(original)
+++ doctools/trunk/sphinx/ext/autodoc.py	Fri Aug 15 21:43:52 2008
@@ -498,10 +498,14 @@
         if _all:
             # unqualified :members: given
             if what == 'module':
-                # for implicit module members, check __module__ to avoid documenting
-                # imported objects if __all__ is not defined
-                members_check_module = not hasattr(todoc, '__all__')
-                all_members = inspect.getmembers(todoc)
+                if hasattr(todoc, '__all__'):
+                    members_check_module = False
+                    all_members = inspect.getmembers(todoc, lambda x: x in todoc.__all__)
+                else:
+                    # for implicit module members, check __module__ to avoid
+                    # documenting imported objects
+                    members_check_module = True
+                    all_members = inspect.getmembers(todoc)
             else:
                 if self.options.inherited_members:
                     # getmembers() uses dir() which pulls in members from all


More information about the Python-checkins mailing list