Respect __all__ when autodocumenting module members.

This commit is contained in:
Georg Brandl 2008-08-15 19:43:52 +00:00
parent a8c1a75e81
commit 37da4a20ed
2 changed files with 10 additions and 4 deletions

View File

@ -45,6 +45,8 @@ New features added
* sphinx.doc.autodoc has a new event ``autodoc-process-signature`` * sphinx.doc.autodoc has a new event ``autodoc-process-signature``
that allows tuning function signature introspection. that allows tuning function signature introspection.
* Respect __all__ when autodocumenting module members.
* Glossary entries are now automatically added to the index. * Glossary entries are now automatically added to the index.
* Added ``exclude_dirnames`` config value that can be used to exclude * Added ``exclude_dirnames`` config value that can be used to exclude

View File

@ -498,10 +498,14 @@ class RstGenerator(object):
if _all: if _all:
# unqualified :members: given # unqualified :members: given
if what == 'module': if what == 'module':
# for implicit module members, check __module__ to avoid documenting if hasattr(todoc, '__all__'):
# imported objects if __all__ is not defined members_check_module = False
members_check_module = not hasattr(todoc, '__all__') all_members = inspect.getmembers(todoc, lambda x: x in todoc.__all__)
all_members = inspect.getmembers(todoc) else:
# for implicit module members, check __module__ to avoid
# documenting imported objects
members_check_module = True
all_members = inspect.getmembers(todoc)
else: else:
if self.options.inherited_members: if self.options.inherited_members:
# getmembers() uses dir() which pulls in members from all # getmembers() uses dir() which pulls in members from all