Fix #7839: autosummary: cannot handle umlauts in function names

This commit is contained in:
Takeshi KOMIYA 2020-06-16 23:18:17 +09:00
parent 8f184e07bb
commit 9c0bf231ab
3 changed files with 7 additions and 5 deletions

View File

@ -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

View File

@ -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]:

View File

@ -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)