
python-checkins at python
Sep 6, 2008, 1:11 PM
Post #1 of 1
(41 views)
Permalink
|
|
r66265 - in doctools/trunk: sphinx/ext/autodoc.py tests/test_autodoc.py
|
|
Author: georg.brandl Date: Sat Sep 6 22:11:04 2008 New Revision: 66265 Log: Fix handling of __all__ for modules and add a test. Modified: doctools/trunk/sphinx/ext/autodoc.py doctools/trunk/tests/test_autodoc.py Modified: doctools/trunk/sphinx/ext/autodoc.py ============================================================================== --- doctools/trunk/sphinx/ext/autodoc.py (original) +++ doctools/trunk/sphinx/ext/autodoc.py Sat Sep 6 22:11:04 2008 @@ -499,7 +499,14 @@ if what == 'module': if hasattr(todoc, '__all__'): members_check_module = False - all_members = inspect.getmembers(todoc, lambda x: x in todoc.__all__) + all_members = [] + for mname in todoc.__all__: + try: + all_members.append((mname, getattr(todoc, mname))) + except AttributeError: + self.warn('missing attribute mentioned in __all__: ' + 'module %s, attribute %s' % + (todoc.__name__, mname)) else: # for implicit module members, check __module__ to avoid # documenting imported objects Modified: doctools/trunk/tests/test_autodoc.py ============================================================================== --- doctools/trunk/tests/test_autodoc.py (original) +++ doctools/trunk/tests/test_autodoc.py Sat Sep 6 22:11:04 2008 @@ -268,9 +268,9 @@ def assert_result_contains(item, *args): gen.generate(*args) + print '\n'.join(gen.result) assert len(gen.warnings) == 0, gen.warnings assert item in gen.result - print '\n'.join(gen.result) del gen.result[:] # no module found? @@ -322,6 +322,16 @@ assert_result_contains(' :deprecated:', 'module', 'test_autodoc', [], None) options.platform = 'Platform' assert_result_contains(' :platform: Platform', 'module', 'test_autodoc', [], None) + # test if __all__ is respected for modules + assert_result_contains('.. class:: Class', 'module', 'test_autodoc', + ['__all__'], None) + try: + assert_result_contains('.. exception:: CustomEx', 'module', 'test_autodoc', + ['__all__'], None) + except AssertionError: + pass + else: + assert False, 'documented CustomEx which is not in __all__' # test noindex flag options.noindex = True @@ -335,6 +345,8 @@ # --- generate fodder ------------ +__all__ = ['Class'] + class CustomEx(Exception): """My custom exception.""" _______________________________________________ Python-checkins mailing list Python-checkins[at]python.org http://mail.python.org/mailman/listinfo/python-checkins
|