Skip to content

Commit

Permalink
Fixed missed ignore___all__ -> ignore_module_all
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoshanuikabundi committed Nov 15, 2021
1 parent 79089b5 commit 8e45229
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGES
Expand Up @@ -16,7 +16,7 @@ Features added
* #9815: html theme: Wrap sidebar components in div to allow customizing their
layout via CSS
* #9831: Autosummary now documents only the members specified in a module's
``__all__`` attribute if :confval:`autosummary_ignore___all__` is set to
``__all__`` attribute if :confval:`autosummary_ignore_module_all` is set to
``False``. The default behaviour is unchanged. Autogen also now supports
this behavior with the ``--respect-module-all`` switch.

Expand Down
2 changes: 1 addition & 1 deletion sphinx/ext/autosummary/__init__.py
Expand Up @@ -826,6 +826,6 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value('autosummary_mock_imports',
lambda config: config.autodoc_mock_imports, 'env')
app.add_config_value('autosummary_imported_members', [], False, [bool])
app.add_config_value('autosummary_ignore___all__', True, 'env', bool)
app.add_config_value('autosummary_ignore_module_all', True, 'env', bool)

return {'version': sphinx.__display_version__, 'parallel_read_safe': True}
14 changes: 7 additions & 7 deletions sphinx/ext/autosummary/generate.py
Expand Up @@ -68,7 +68,7 @@ def __init__(self, translator: NullTranslations) -> None:

self.config.add('autosummary_context', {}, True, None)
self.config.add('autosummary_filename_map', {}, True, None)
self.config.add('autosummary_ignore___all__', True, 'env', bool)
self.config.add('autosummary_ignore_module_all', True, 'env', bool)
self.config.init_values()

def emit_firstresult(self, *args: Any) -> None:
Expand Down Expand Up @@ -219,7 +219,7 @@ def scan(self, imported_members: bool) -> List[str]:
elif imported is False:
# list not-imported members
members.append(name)
elif '__all__' in dir(self.object) and not self.app.config.autosummary_ignore___all__:
elif '__all__' in dir(self.object) and not self.app.config.autosummary_ignore_module_all:
# list members that have __all__ set
members.append(name)

Expand All @@ -228,9 +228,9 @@ def scan(self, imported_members: bool) -> List[str]:
def members_of(conf: Config, obj: Any) -> Sequence[str]:
"""Get the members of ``obj``, possibly ignoring the ``__all__`` module attribute
Follows the ``conf.autosummary_ignore___all__`` setting."""
Follows the ``conf.autosummary_ignore_module_all`` setting."""

if conf.autosummary_ignore___all__:
if conf.autosummary_ignore_module_all:
return dir(obj)
else:
return getall(obj) or dir(obj)
Expand Down Expand Up @@ -645,8 +645,8 @@ def get_parser() -> argparse.ArgumentParser:
dest='imported_members', default=False,
help=__('document imported members (default: '
'%(default)s)'))
parser.add_argument('-a', '--respect-module-all', action='store_false',
dest='ignore___all__', default=True,
parser.add_argument('-a', '--respect-module-all', action='store_true',
dest='respect_module_all', default=False,
help=__('document exactly the members in module __all__ attribute. '
'(default: %(default)s)'))

Expand All @@ -665,7 +665,7 @@ def main(argv: List[str] = sys.argv[1:]) -> None:

if args.templates:
app.config.templates_path.append(path.abspath(args.templates))
app.config.autosummary_ignore___all__ = args.ignore___all__
app.config.autosummary_ignore_module_all = not args.respect_module_all

generate_autosummary_docs(args.source_file, args.output_dir,
'.' + args.suffix,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ext_autosummary.py
Expand Up @@ -238,7 +238,7 @@ def test_autosummary_generate_content_for_module(app):
def test_autosummary_generate_content_for_module___all__(app):
import autosummary_dummy_module
template = Mock()
app.config.autosummary_ignore___all__ = False
app.config.autosummary_ignore_module_all = False

generate_autosummary_content('autosummary_dummy_module', autosummary_dummy_module, None,
template, None, False, app, False, {})
Expand Down

0 comments on commit 8e45229

Please sign in to comment.