diff --git a/CHANGES b/CHANGES index 85a4f9def..b22e05b8f 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,7 @@ Features added Bugs fixed ---------- +* #7839: autosummary: cannot handle umlauts in function names * #7715: LaTeX: ``numfig_secnum_depth > 1`` leads to wrong figure links Testing diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index 162b6868c..7eaefd4b1 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -755,7 +755,8 @@ def process_generate_options(app: Sphinx) -> None: with mock(app.config.autosummary_mock_imports): generate_autosummary_docs(genfiles, suffix=suffix, base_path=app.srcdir, app=app, imported_members=imported_members, - overwrite=app.config.autosummary_generate_overwrite) + overwrite=app.config.autosummary_generate_overwrite, + encoding=app.config.source_encoding) def setup(app: Sphinx) -> Dict[str, Any]: diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py index fe7daf214..7583d9894 100644 --- a/sphinx/ext/autosummary/generate.py +++ b/sphinx/ext/autosummary/generate.py @@ -347,7 +347,7 @@ def generate_autosummary_docs(sources: List[str], output_dir: str = None, info: Callable = None, base_path: str = None, builder: Builder = None, template_dir: str = None, imported_members: bool = False, app: Any = None, - overwrite: bool = True) -> None: + overwrite: bool = True, encoding: str = 'utf-8') -> None: if info: warnings.warn('info argument for generate_autosummary_docs() is deprecated.', RemovedInSphinx40Warning, stacklevel=2) @@ -415,17 +415,17 @@ def generate_autosummary_docs(sources: List[str], output_dir: str = None, filename = os.path.join(path, name + suffix) if os.path.isfile(filename): - with open(filename) as f: + with open(filename, encoding=encoding) as f: old_content = f.read() if content == old_content: continue elif overwrite: # content has changed - with open(filename, 'w') as f: + with open(filename, 'w', encoding=encoding) as f: f.write(content) new_files.append(filename) else: - with open(filename, 'w') as f: + with open(filename, 'w', encoding=encoding) as f: f.write(content) new_files.append(filename)