Skip to content

Fix docutils doctest table width compatibility - #14681

Open
Darlokt wants to merge 6 commits into
sphinx-doc:masterfrom
Darlokt:fix-docutils-doctest-table-width-compatibility
Open

Darlokt wants to merge 6 commits into
sphinx-doc:masterfrom
Darlokt:fix-docutils-doctest-table-width-compatibility

Conversation

@Darlokt

@Darlokt Darlokt commented Sep 13, 2026

Copy link
Copy Markdown

Purpose

Hej,
this fixes the Docutils 1.0 compatibility issues reported in #14680.

Docutils 1.0 development versions represent native doctests as literal_block nodes and proportional table widths as strings.

Sphinx now recognizes both the old and new doctest forms when collecting, highlighting, and positioning them, while continuing to exclude ordinary pycon code blocks from doctest runs.

Autosummary now emits string widths on all supported Docutils versions.
The text, LaTeX, and Texinfo writers validate and convert integer or proportional string widths before arithmetic without mutating the doctree.

The declared docutils>=0.21,<0.23 dependency range is unchanged, as 1.0 is unreleased.

References

AI Disclosure

OpenAI Codex assisted with reviewing and generating parts of the compatibility changes nd regression tests.
For the shared node predicates and column-width conversion, their integrations nd the associated tests were AI reviewed and generated parts.
All AI-assisted work was reviewed and understood by me.

@Darlokt

Darlokt commented Sep 16, 2026

Copy link
Copy Markdown
Author

Sorry, after a bit of thinking, I thought I could do better.
I added native doctest handling to gettext extraction, where Docutils 1.0 doctests were still treated as ordinary literal_block nodes.
I also replaced/removed the shared column-width parser and replaced it with a direct int() conversion. Docutils 1.0 only changes widths from integers to numeric strings.
The previous helper only partially anticipated the planned Docutils 2.0 changes. It handled integral values such as 5*, but not decimal proportions such as 8.2*, fixed widths such as 2.5cm, or mixtures of fixed and proportional columns.
Those require table-level normalization and writer-specific handling, so I think they should be revisited/implemented together when Sphinx adds Docutils 2.0 support, with the minimal change here for now being enouhgh for 1.0.

@Darlokt

Darlokt commented Sep 18, 2026

Copy link
Copy Markdown
Author

d3ed5fa adds a shared parser for the text, LaTeX, and Texinfo writers so Docutils 1.0 integral strings remain supported.
Rejects floats instead of making LaTeX's incidental late truncation the default behavior for the Text and Texinfo writers.

@Darlokt

Darlokt commented Sep 19, 2026

Copy link
Copy Markdown
Author

The failures are flakey tests and the missing changes from #14689. I keep the separate, as they solve different issues, merging the two would resolve the Docutils HEAD failures.

@saitanallensantiago26-beep

Copy link
Copy Markdown

Purpose

Hej,
this fixes the Docutils 1.0 compatibility issues reported in #14680.

Docutils 1.0 development versions represent native doctests as literal_block nodes and proportional table widths as strings.

Sphinx now recognizes both the old and new doctest forms when collecting, highlighting, and positioning them, while continuing to exclude ordinary pycon code blocks from doctest runs.

Autosummary now emits string widths on all supported Docutils versions.
The text, LaTeX, and Texinfo writers validate and convert integer or proportional string widths before arithmetic without mutating the doctree.

The declared docutils>=0.21,<0.23 dependency range is unchanged, as 1.0 is unreleased.

References

AI Disclosure

OpenAI Codex assisted with reviewing and generating parts of the compatibility changes nd regression tests.
For the shared node predicates and column-width conversion, their integrations nd the associated tests were AI reviewed and generated parts.
All AI-assisted work was reviewed and understood by me.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docutils 1.0 development changes break native doctests and table widths

2 participants