Skip to content
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

CSS extracts: Link entries back to spec anchor #1468

Merged
merged 3 commits into from
Jan 29, 2024
Merged

CSS extracts: Link entries back to spec anchor #1468

merged 3 commits into from
Jan 29, 2024

Conversation

tidoust
Copy link
Member

@tidoust tidoust commented Jan 25, 2024

Requested in w3c/webref#642

It was possible to link entries in CSS extracts back to entries in the dfns extract with a bit of logic but:

  1. This requires having both CSS extracts and dfns extracts at hand, and the dfns extracts typically aren't included in the @webref/idl package.
  2. This is somewhat error-prone.

This updates the CSS definitions extraction logic to also extract the absolute URL (with fragment) of the definition whenever possible. A slight change of approach was needed as previous extraction logic handled "multi-definitions" (e.g., a table definition that defines multiple properties at once) through a text-based approach, and the code now also needs to track the IDs.

Tests already contained IDs, so this update merely refreshes the expected results.

Requested in w3c/webref#642

It was possible to link entries in CSS extracts back to entries in the dfns
extract with a bit of logic but:
1. This requires having both CSS extracts and dfns extracts at hand, and the
dfns extracts typically aren't included in the `@webref/idl` package.
2. This is somewhat error-prone.

This updates the CSS definitions extraction logic to also extract the absolute
URL (with fragment) of the definition whenever possible. A slight change of
approach was needed as previous extraction logic handled "multi-definitions"
(e.g., a table definition that defines multiple properties at once) through a
text-based approach, and the code now also needs to track the IDs.

Tests already contained IDs, so this update merely refreshes the expected
results.
@tidoust
Copy link
Member Author

tidoust commented Jan 26, 2024

This seems to work surprisingly well in practice, in that all entries seem to end up with an href property, except when a spec somehow extends a base definition, in other words:

  1. Definitions that have a newValues key typically don't have an href property.
  2. At-rules that neither have a prose nor a value key usually don't have an href property.
  3. The contain property in the css-contain-3 delta spec does not have an href property, because the property is defined in css-contain-2. Plus it wouldn't be fun without an exceptional case.

Important note: This adds a property to most entries in CSS extracts, which will invalidate the CSS patches in Webref. We'll have to re-generate them. Not too hard... but painful :/

@tidoust tidoust marked this pull request as ready for review January 26, 2024 13:59
@tidoust tidoust requested a review from dontcallmedom January 26, 2024 13:59
@tidoust tidoust merged commit dead276 into main Jan 29, 2024
1 check passed
@tidoust tidoust deleted the css-dfn-href branch January 29, 2024 08:15
tidoust added a commit that referenced this pull request Jan 29, 2024
New feature:
- CSS extracts: Link entries back to spec anchor (#1468)

Dependency bumped:
- Bump undici from 6.4.0 to 6.5.0 (#1471)

The new feature introduces a change in the schema of CSS extracts to add an
`href` property to most entries.
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.

2 participants