refactor(css-syntax): drop the hardcoded type slug map - #877
Open
caugner wants to merge 4 commits into
Open
Conversation
Contributor
|
239094c was deployed to: https://rari-pr877.review.mdn.allizom.net/ |
LeoMcA
approved these changes
Sep 4, 2026
caugner
marked this pull request as draft
September 4, 2026 13:35
caugner
marked this pull request as ready for review
September 4, 2026 13:58
`render_node` special-cased five type names (`<color>` -> `color_value`, `<contrast-color()>` -> `color_value/contrast-color`, …) to patch up MDN's page layout. The `CSS_FEATURE_INDEX` resolver now derives all five from the page tree via its `_value`/`_function` and leaf aliases, so the map only duplicates that knowledge in the crate that shouldn't own it. Also drop the `!skip(slug)` guard from the same branch: `skip()` already keeps `<color>` and `<gradient>` out of `get_nodes_for_syntaxes`, so they never reach `SyntaxRenderer::constituents` and the guard could not fire. `skip()` itself stays, since its other two call sites govern constituent expansion rather than linking. Verified as a no-op: building all 1256 en-US `Web/CSS` pages before and after produces byte-identical `index.json` output. The `test_render_terms` snapshot changes because it renders with `resolver: None`, which now links the two function types under their bare names instead of the mapped ones. That path only applies to callers without a page index.
The name now says what the check governs, so the doc comment explaining that it is about expansion rather than linking is redundant.
It described a removed special case rather than the current code.
With `resolver: None` the snapshot asserted links that MDN does not have, such as `Values/device-cmyk()` for a function documented under `Values/color_value/device-cmyk`. Resolve through a stub that only knows the pages that exist, so the snapshot shows the nested function paths and leaves undocumented types unlinked.
caugner
force-pushed
the
csssyntax-drop-redundant-slug-map
branch
from
September 4, 2026 14:05
6b567bd to
74be60a
Compare
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.
Description
Remove the five-entry hardcoded type slug map from
SyntaxRenderer::render_node, along with the now-unreachable!skip(slug)guard in the same branch. Renameskip()toshould_skip_expansion()to say what its remaining call sites govern.Motivation
The map (
<color>tocolor_value,<contrast-color()>tocolor_value/contrast-color, …) encoded MDN's page layout insidecss-syntax, which has no business knowing it. TheCSS_FEATURE_INDEXresolver added in #874 derives all five from the page tree via its_value/_functionand leaf aliases, so the map now only duplicates that knowledge in the wrong crate.Additional details
Verified as a no-op: building all 1256 en-US
Web/CSSpages before and after produces byte-identicalindex.jsonoutput. (The only diff is element ordering inmetadata.json, which is nondeterministic and identical as a set.)should_skip_expansion()(formerlyskip()) itself stays. Its two other call sites govern constituent expansion rather than linking, and because they keep<color>and<gradient>out ofget_nodes_for_syntaxes, those types never reachSyntaxRenderer::constituentsand the!skip(slug)guard inrender_nodecould never fire.test_render_termspreviously rendered withresolver: None, whose default-category fallback produced links MDN does not have (e.g.Values/contrast-color()). It now resolves through a stub standing in for the page index, so the snapshot shows the nestedcolor_value/…paths for the two function types and leaves undocumented types unlinked.Related issues and pull requests
Depends on: #874, which adds the resolver that makes the map redundant.