Skip to content

Conversation

@chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Jan 19, 2026

This PR adds support for Sphinx 9.x while maintaining backward compatibility with Sphinx 7.x and 8.x. The changes address a breaking change in docutils 0.22+ regarding boolean attribute serialization in XML output.

Changes:

  • Updated dependency version constraints to support Sphinx 9 and myst-parser 4-5
  • Added Sphinx 9.0 to the CI test matrix for Ubuntu and Windows environments
  • Introduced XML normalization fixture to handle docutils 0.22+ boolean serialization changes

- Update sphinx dependency to allow version 9 (`sphinx>=7,<10`)
- Add Sphinx 9.0 to CI test matrix (Ubuntu and Windows)
- Bump myst-parser dependency to `>=4,<6`
- Fix test compatibility with docutils 0.22+ boolean attribute serialization
  (normalizes `"1"`/`"0"` back to `"True"`/`"False"` in XML output)
@chrisjsewell chrisjsewell requested a review from Copilot January 19, 2026 12:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for Sphinx 9.x while maintaining backward compatibility with Sphinx 7.x and 8.x. The changes address a breaking change in docutils 0.22+ regarding boolean attribute serialization in XML output.

Changes:

  • Updated dependency version constraints to support Sphinx 9 and myst-parser 4-5
  • Added Sphinx 9.0 to the CI test matrix for Ubuntu and Windows environments
  • Introduced XML normalization fixture to handle docutils 0.22+ boolean serialization changes

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pyproject.toml Updated version constraints for sphinx (<10) and myst-parser (>=4,<6) dependencies
.github/workflows/ci.yml Added Sphinx 9.0 testing to CI matrix for Ubuntu and Windows
tests/conftest.py Added normalize_doctree_xml fixture to normalize boolean attributes across docutils versions
tests/test_snippets.py Updated test functions to use the new normalize_doctree_xml fixture

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chrisjsewell chrisjsewell merged commit 6c906da into main Jan 19, 2026
24 checks passed
@chrisjsewell chrisjsewell deleted the sphinx-9 branch January 19, 2026 12:58
Comment on lines +98 to +128
@pytest.fixture
def normalize_doctree_xml():
"""Normalize docutils XML output for cross-version compatibility.

In docutils 0.22+, boolean attributes are serialized as "1"/"0"
instead of "True"/"False". This function normalizes to the old format
for consistent test fixtures.
"""

def _normalize(text: str) -> str:
if DOCUTILS_0_22_PLUS:
# Normalize new format (1/0) to old format (1/0)
# Only replace when it's clearly a boolean attribute value
# Pattern: attribute="1" or attribute="0"
attrs = [
"checked",
"force",
"has_title",
"internal",
"is_div",
"linenos",
"opened",
"refexplicit",
"refwarn",
"selected",
]
text = re.sub(rf' ({"|".join(attrs)})="1"', r' \1="True"', text)
text = re.sub(rf' ({"|".join(attrs)})="0"', r' \1="False"', text)
return text

return _normalize
Copy link

@amotl amotl Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also use that in downstream projects. Maybe relocate to sphinx_design_elements.testing, to be able to ship it with the package?

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.

Test suite compatibility with docutils 0.22 Support Sphinx v9 Please test with Sphinx 9

3 participants