diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-06-19 01:05:47 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-06-19 14:03:42 +0900 |
commit | 1aa1373ce34f15a7a730c5a0df40264574649af2 (patch) | |
tree | aa1af4c833c36dca82998040794ce2213461e6c8 /sphinx/ext/autosummary/__init__.py | |
parent | c78018cda7f32b060966d57af0c5cef1880e89c0 (diff) | |
download | sphinx-git-1aa1373ce34f15a7a730c5a0df40264574649af2.tar.gz |
Fix #6498: autosummary: crashed with wrong autosummary_generate setting
Diffstat (limited to 'sphinx/ext/autosummary/__init__.py')
-rw-r--r-- | sphinx/ext/autosummary/__init__.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index 6eb0fea9b..19c400609 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -58,6 +58,7 @@ import posixpath import re import sys import warnings +from os import path from types import ModuleType from typing import List, cast @@ -731,26 +732,31 @@ def process_generate_options(app): # type: (Sphinx) -> None genfiles = app.config.autosummary_generate - if genfiles and not hasattr(genfiles, '__len__'): + if genfiles is True: env = app.builder.env genfiles = [env.doc2path(x, base=None) for x in env.found_docs if os.path.isfile(env.doc2path(x))] + else: + ext = list(app.config.source_suffix) + genfiles = [genfile + (not genfile.endswith(tuple(ext)) and ext[0] or '') + for genfile in genfiles] + + for entry in genfiles[:]: + if not path.isfile(path.join(app.srcdir, entry)): + logger.warning(__('autosummary_generate: file not found: %s'), entry) + genfiles.remove(entry) if not genfiles: return - from sphinx.ext.autosummary.generate import generate_autosummary_docs - - ext = list(app.config.source_suffix) - genfiles = [genfile + (not genfile.endswith(tuple(ext)) and ext[0] or '') - for genfile in genfiles] - suffix = get_rst_suffix(app) if suffix is None: logger.warning(__('autosummary generats .rst files internally. ' 'But your source_suffix does not contain .rst. Skipped.')) return + from sphinx.ext.autosummary.generate import generate_autosummary_docs + imported_members = app.config.autosummary_imported_members with mock(app.config.autosummary_mock_imports): generate_autosummary_docs(genfiles, builder=app.builder, |