Commits

Anonymous committed 4da54b9

Respect __all__ when autodocumenting module members.

  • Participants
  • Parent commits 12c62cf

Comments (0)

Files changed (2)

 * 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

File sphinx/ext/autodoc.py

         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