Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autosummary may output .md files with MyST-Parser #12147

Closed
kou opened this issue Mar 20, 2024 · 0 comments · Fixed by #12149
Closed

autosummary may output .md files with MyST-Parser #12147

kou opened this issue Mar 20, 2024 · 0 comments · Fixed by #12149
Labels

Comments

@kou
Copy link
Contributor

kou commented Mar 20, 2024

Describe the bug

If we have the following configurations, autosummary generates .md files with reST content:

extensions = ['myst_parser', 'sphinx.ext.autosummary']
source_suffix = {
    '.md': 'markdown',
    '.rst': 'restructuredtext',
}
autosummary_generate = True

autosummary should generate .rst files because they use reST.

Note that if we use the following order for source_suffix, autosummary generates .md files:

source_suffix = {
    '.rst': 'restructuredtext',
    '.md': 'markdown',
}

How to Reproduce

Create a new project:

$ sphinx-quickstart /tmp/sphinx-test

Add the following configurations to conf.py:

extensions = ['myst_parser', 'sphinx.ext.autosummary']
source_suffix = {
    '.md': 'markdown',
    '.rst': 'restructuredtext',
}
autosummary_generate = True

Add the following content to index.rst:

.. currentmodule:: sphinx

.. autosummary::
   :toctree: generated/

   environment.BuildEnvironment

Generate document:

$ make -C /tmp/sphinx-test html

Check generated files:

$ ls -lh /tmp/sphinx-test/generated
total 4.0K
-rw-r--r-- 1 kou kou 1.4K Mar 21 00:13 sphinx.environment.BuildEnvironment.md

It has .md suffix not .rst suffix.

Environment Information

Platform:              linux; (Linux-6.6.15-amd64-x86_64-with-glibc2.37)
Python version:        3.11.8 (main, Feb  7 2024, 21:52:08) [GCC 13.2.0])
Python implementation: CPython
Sphinx version:        7.3.0+/3bedde26a
Docutils version:      0.20.1
Jinja2 version:        3.1.2
Pygments version:      2.17.2

Sphinx extensions

['myst_parser', 'sphinx.ext.autosummary']

Additional context

No response

@kou kou added the type:bug label Mar 20, 2024
kou added a commit to kou/sphinx that referenced this issue Mar 20, 2024
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`.
kou added a commit to kou/sphinx that referenced this issue Mar 21, 2024
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`.
kou added a commit to kou/sphinx that referenced this issue Mar 21, 2024
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`.
kou added a commit to kou/sphinx that referenced this issue Mar 22, 2024
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`.
kou added a commit to kou/sphinx that referenced this issue Mar 22, 2024
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`.
kou added a commit to kou/arrow that referenced this issue Mar 22, 2024
AlenkaF pushed a commit to apache/arrow that referenced this issue Mar 25, 2024
### Rationale for this change

Sphinx < 7.3.0 has a problem that auto generated files may use wrong suffix.

See sphinx-doc/sphinx#12147 for details.

### What changes are included in this PR?

Use `.rst` as the first `source_suffix` item as a workaround of this problem.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* GitHub Issue: #40623

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: AlenkaF <frim.alenka@gmail.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant