Skip to content

Commit

Permalink
[autosummary] fix suffix detection
Browse files Browse the repository at this point in the history
fix sphinx-doc#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`.
  • Loading branch information
kou committed Mar 22, 2024
1 parent 4eede5c commit 6e39a97
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -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
-------
Expand Down
2 changes: 1 addition & 1 deletion sphinx/ext/autosummary/__init__.py
Expand Up @@ -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
Expand Down

0 comments on commit 6e39a97

Please sign in to comment.