-
Notifications
You must be signed in to change notification settings - Fork 65
⬆️ Add Sphinx 9 support #255
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
Conversation
- 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)
for more information, see https://pre-commit.ci
There was a problem hiding this 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.
| @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 |
There was a problem hiding this comment.
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?
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: