Repository navigation
Description
Describe the bug
Hej,
this is the last of the the CI failures on #14677. I noticed that two node representation changes in the Docutils 1.0 development version break Sphinx's handling of native reStructuredText doctests and table column widths.
Docutils now parses a native doctest as a literal_block with the classes code, pycon, and doctest, instead of as a doctest_block.
Sphinx only recognizes the old node type when it assigns the highlighting language, collects automatic doctests, and moves an indented native doctest out of a block quote.
The new node can therefore lack a language attribute, be skipped by the doctest builder, and remain inside a <blockquote> in HTML.
Docutils also represents proportional colwidth attributes as strings.
Sphinx's text, LaTeX, and Texinfo writers perform integer arithmetic on these values, while autosummary still creates integer attributes that the Docutils development XML writer treats as strings. This produces errors in both directions at the Sphinx/Docutils boundary.
How to Reproduce
Run:
uv sync
uv run --no-sync --with \
'docutils @ git+https://repo.or.cz/docutils.git@335c924f838ac9180231cf2164f301cc6f6b4ca1#subdirectory=docutils' \
pytest -q --tb=short \
tests/test_builders/test_build_text.py::test_lineblock \
tests/test_extensions/test_ext_doctest.py::test_highlight_language_default \
tests/test_ext_autosummary/test_ext_autosummary.py::test_escapingThe run produces three failed tests and exit code 1:
- the text writer failed while combining integer and string column width
- the doctest highlighting test failed with
KeyError: 'language' - the XML writer failed while handling autosummary's integer
colwidth
The same three tests pass with the locked Docutils 0.22.3.
Environment Information
Platform: linux; (Linux-7.0.0-31-generic-x86_64-with-glibc2.43)
Python version: 3.13.13 (main, Apr 7 2026, 20:49:46) [Clang 22.1.1 ])
Python implementation: CPython
Sphinx version: 9.1.1+/e44a40eb2
Docutils version: 1.0b1.dev
Jinja2 version: 3.1.6
Pygments version: 2.19.2
Sphinx extensions
['sphinx.ext.autosummary', 'sphinx.ext.doctest']Additional context
The AI under #14673 already proposes changes to the same compatibility surfaces, but it misses the transform that moves indented native doctests out of block quotes.
Activity
Darlokt commentedon Sep 18, 2026
Hej, @jdillard I was checking the upstream Docutils 1.0 plans, while making #14689, with #14681, we currently cover the current failures, but there are some additions planned that could still affect sphinx, I made this small table of what I could find in the Docutils changes that affect Sphinx (with the help of AI to aggregate all the open already issues and PRs and summarize upstream changes):
doctest_blockto classifiedliteral_blocknodes; tablecolwidthvalues changed from integers to stringshttps://www.rfc-editor.org/info/, and generated RFC paths no longer end in.htmlDanglingReferencessplit intoMatchReferences,ReportDanglingReferences, andReportUnreferencedTargetsReportUnreferencedTargetsas unsuitable for Sphinx's multi-document model<div>but inherits Docutils' attribution handling. The upstream change may alter Sphinx's HTML structure or conflict with its wrapper markup and themestext_referencesdefault toFalsevisit_reference. The new default will select different Docutils rendering unless Sphinx controls dispatch itselfSOURCE_DATE_EPOCHfor the Docutilsdatedirective anddatestampsettingSOURCE_DATE_EPOCHelsewhere. The change is likely desirable but needs a Sphinx regression testDanglingReferences, or import removed Docutils APIsThe last one is more indirect, as it doesnt affect Sphinx with its current test suite, but may other extensions.
Should maybe a tracking issue be opened to track Docutils 1.0 compatibility, as it seem they are currently landing one by one in dev so one can keep track of what is already landed, if it is addressed etc.
Darlokt commentedon Sep 19, 2026
I added the PR by @jayaddison to the table (#14696 provides a partial fix to #14680 and doesnt fix #14659, adjusting tests to pass for now.)
doctest_blockto classifiedliteral_blocknodes; tablecolwidthvalues changed from integers to stringshttps://www.rfc-editor.org/info/, and generated RFC paths no longer end in.htmlDanglingReferencessplit intoMatchReferences,ReportDanglingReferences, andReportUnreferencedTargetsReportUnreferencedTargetsas unsuitable for Sphinx's multi-document model<div>but inherits Docutils' attribution handling. The upstream change may alter Sphinx's HTML structure or conflict with its wrapper markup and themestext_referencesdefault toFalsevisit_reference. The new default will select different Docutils rendering unless Sphinx controls dispatch itselfSOURCE_DATE_EPOCHfor the Docutilsdatedirective anddatestampsettingSOURCE_DATE_EPOCHelsewhere. The change is likely desirable but needs a Sphinx regression testDanglingReferences, or import removed Docutils APIsgmilde commentedon Sep 19, 2026
Support of the environment variable SOURCE_DATE_EPOCH is now done (Docutils commit r10402).
Darlokt commentedon Sep 19, 2026
Thanks @gmilde , I will get at it.
doctest_blockto classifiedliteral_blocknodes; tablecolwidthvalues changed from integers to stringshttps://www.rfc-editor.org/info/, and generated RFC paths no longer end in.htmlDanglingReferencessplit intoMatchReferences,ReportDanglingReferences, andReportUnreferencedTargetsReportUnreferencedTargetsas unsuitable for Sphinx's multi-document model<div>but inherits Docutils' attribution handling. The upstream change may alter Sphinx's HTML structure or conflict with its wrapper markup and themestext_referencesdefault toFalsevisit_reference. The new default will select different Docutils rendering unless Sphinx controls dispatch itselfSOURCE_DATE_EPOCHfor the Docutilsdatedirective anddatestampsettingSOURCE_DATE_EPOCHelsewhere. The change is likely desirable but needs a Sphinx regression testDanglingReferences, or import removed Docutils APIsgmilde commentedon Oct 9, 2026
"Move HTML5 attribution markup after its blockquote" is now complete.
Darlokt commentedon Oct 21, 2026
Thanks @gmilde , sorry for the delay, it should be up to date now again.
doctest_blockto classifiedliteral_blocknodes; tablecolwidthvalues changed from integers to stringshttps://www.rfc-editor.org/info/, and generated RFC paths no longer end in.htmlDanglingReferencessplit intoMatchReferences,ReportDanglingReferences, andReportUnreferencedTargetsReportUnreferencedTargetsas unsuitable for Sphinx's multi-document model<div>but inherits Docutils' attribution handling. The upstream change may alter Sphinx's HTML structure or conflict with its wrapper markup and themestext_referencesdefault toFalsevisit_reference. The new default will select different Docutils rendering unless Sphinx controls dispatch itselfSOURCE_DATE_EPOCHfor the Docutilsdatedirective anddatestampsettingSOURCE_DATE_EPOCHelsewhere. The change is likely desirable but needs a Sphinx regression testDanglingReferences, or import removed Docutils APIsDarlokt commentedon Oct 21, 2026
@AA-Turner, how would you like to proceed with the remaining Docutils 1.0 compatibility work?
d19cbb5 addresses several of the problems tracked here, so some open PRs now overlap with those changes, personally:
SOURCE_DATE_EPOCHhandling across supported Docutils versions, including compatibility handling for older releases.Should these be updated as focused follow-ups to the committed changes, as they do normalize behavior, but also change it slightly? It would help to know which remaining differences between Docutils versions you would like Sphinx to normalize, and which should remain version-dependent as we look forward to Docutils 1.0?