From 6e39a97f2fb5dbfe675283d54f834f4dcaed4dd0 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Thu, 21 Mar 2024 00:24:09 +0900 Subject: [PATCH] [autosummary] fix suffix detection fix #12147 `SphinxComponentRegistry.source_parsers` uses `rst`, `md` and so on (without `.`) as key but `source_suffix` in `conf.py` uses `.rst`, `md` and so on (with `.`) as key. So we need to remove preceding `.` from suffixes from `source_suffix` to detect supported format from `SphinxComponentRegistry.source_parsers`. --- CHANGES.rst | 2 ++ sphinx/ext/autosummary/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index afaab82308f..642a3968bf2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -127,6 +127,8 @@ Bugs fixed Patch by James Addison. * #11578: HTML Search: Order non-main index entries after other results. Patch by Brad King. +* #12147: autosummary: Fix a bug that wrong suffix may be used with multiple ``source_suffix``. + Patch by Sutou Kouhei. Testing ------- diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index 93ce819e14a..4d8618444d1 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -770,7 +770,7 @@ def run(self) -> tuple[list[Node], list[system_message]]: def get_rst_suffix(app: Sphinx) -> str | None: def get_supported_format(suffix: str) -> tuple[str, ...]: - parser_class = app.registry.get_source_parsers().get(suffix) + parser_class = app.registry.get_source_parsers().get(suffix.removeprefix('.')) if parser_class is None: return ('restructuredtext',) return parser_class.supported