diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index 1381b4eff..39b00ce9d 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -704,7 +704,7 @@ def process_generate_options(app): return recursion_limit = app.config.autosummary_recursion_limit - + with mock(app.config.autosummary_mock_imports): generate_autosummary_docs(genfiles, builder=app.builder, warn=logger.warning, info=logger.info, @@ -734,7 +734,7 @@ def setup(app): app.connect('doctree-read', process_autosummary_toc) app.connect('builder-inited', process_generate_options) app.add_config_value('autosummary_generate', [], True, [bool]) - app.add_config_value('autosummary_recursion_limit', 0, 0) + app.add_config_value('autosummary_recursion_limit', 0, True, [int]) app.add_config_value('autosummary_mock_imports', lambda config: config.autodoc_mock_imports, 'env') return {'version': sphinx.__display_version__, 'parallel_read_safe': True} diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py index 27974eeac..e1bdfdef8 100644 --- a/sphinx/ext/autosummary/generate.py +++ b/sphinx/ext/autosummary/generate.py @@ -91,12 +91,19 @@ def _underline(title, line='='): # -- Generating output --------------------------------------------------------- -def generate_autosummary_docs(sources, output_dir=None, suffix='.rst', - warn=_simple_warn, info=_simple_info, - base_path=None, builder=None, template_dir=None, - imported_members=False, recursion_limit=0, - app=None): - # type: (List[str], str, str, Callable, Callable, str, Builder, str, bool, Any) -> None +def generate_autosummary_docs(sources, # type: List[str] + output_dir=None, # type: str + suffix='.rst', # type: str + warn=_simple_warn, # type: Callable + info=_simple_info, # type: Callable + base_path=None, # type: str + builder=None, # type: Builder + template_dir=None, # type: str + imported_members=False, # type: bool + recursion_limit=0, # type: int + app=None # type: Any + ): + # type: (...) -> None showed_sources = list(sorted(sources)) if len(showed_sources) > 20: showed_sources = showed_sources[:10] + ['...'] + showed_sources[-10:] @@ -211,7 +218,7 @@ def generate_autosummary_docs(sources, output_dir=None, suffix='.rst', return public, items def get_package_members(obj, typ, include_public=[]): - # type: (Any, bool, List[str]) -> Tuple[List[str], List[str]] + # type: (Any, str, List[str]) -> Tuple[List[str], List[str]] items = [] # type: List[str] pkg_required = typ == 'package' for _, modname, ispkg in pkgutil.iter_modules(obj.__path__):