Repository navigation
🧪 Make the MyST-dependent tests pass on MyST-Parser 5.1.0 and master - #310
Merged
Merged
Conversation
`test_ref_badge_tooltip_survives_resolution` counted every `href="#my-target"` in the page. With MyST-Parser master (heading-anchor rework, executablebooks/MyST-Parser#1158) the explicit `(my-target)=` becomes the section's primary id, so the theme's headerlink and sidebar TOC also link to `#my-target` and the count is 4, not 2. Count only the anchors carrying the `sd-badge` class, which is what the assertion is about; it holds on MyST-Parser 5.1.0 and on master.
The RST and MyST snippet tests compare against one shared fixture. For a section with an explicit target, docutils lists the title slug first (`clickable-cards cards-clickable`), while MyST-Parser master (heading-anchor rework, executablebooks/MyST-Parser#1158) lists the explicit target first, so `test_snippets_myst[html-card-link]` and `test_snippets_myst_post[html-card-link]` fail on master. The order is a parser detail, not sphinx-design output: sort each element's ids before serialising, in all four snippet tests, and regenerate the two card-link fixtures (one line each). The full set of ids is still compared.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #310 +/- ##
=======================================
Coverage 92.63% 92.63%
=======================================
Files 13 13
Lines 1371 1371
=======================================
Hits 1270 1270
Misses 101 101
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
MyST-Parser master (723cffc, the coming 5.2.0) reworks heading anchors (executablebooks/MyST-Parser#1158):
for a heading with an explicit
(target)=, the target becomes the section's first (primary) id.That breaks three sphinx-design tests, although sphinx-design's own output is unchanged:
test_snippets.py::test_snippets_myst[html-card-link]andtest_snippets_myst_post[html-card-link]:the section's
idsflip fromclickable-cards cards-clickabletocards-clickable clickable-cards.The RST and MyST snippets share one fixture, and docutils keeps the old order, so no single fixture fits both.
test_badge_tooltips.py::test_ref_badge_tooltip_survives_resolution[html-myst]:it counted every
href="#my-target"in the page (4 != 2),because the theme's headerlink and sidebar TOC now also point at
#my-target.This PR changes tests only:
sd-badgeclass that link to#my-target, which is what the assertion is about.idsbefore serialising, in all four snippet tests (RST and MyST, pre and post transforms),and regenerate the two
card-linkfixtures. One line changes in each. The full set of ids is still compared; only their order is ignored.No other fixture changes. Landing this before the MyST-Parser 5.2.0 tag keeps sphinx-design's CI green when 5.2.0 is released
(the
testingextra allowsmyst-parser>=4,<6).How it was tested
Python 3.13, Sphinx 9.2.0, with
pytest tests:main(before)git+https://github.com/executablebooks/MyST-Parser@master), docutils 0.23testing-no-myst(Python 3.11, Sphinx 9.0.4)The 5.1.0 environment was checked to be the real release (its metadata requires
docutils<0.23; master's__version__is also 5.1.0).The sorting is needed. With it disabled and the new fixtures kept,
tests/test_snippets.pyfails on both versions:on 5.1.0 all four
card-linktests fail (2 RST, 2 MyST), and on master the 2 RSTcard-linktests fail.pre-commit run --all-filespasses.Notes for the reviewer
sort_idsis a local helper intests/test_snippets.py.It is deliberately not part of the semi-public
sphinx_design.testing.normalize_doctree_xml,so downstream extensions that use that helper do not get churn in their own fixtures.
card-linksnippets, so itscard-linkfixtures must be regenerated.Doing that on top of this PR records sorted ids, which do not depend on the MyST version.