Add check for syntax parsing and connectivity, fix missed syntaxes
There are pretty common problems when updating CSS syntax dictionaries:
- added/updated definition can't be parsed;
- a new syntax has broken references to other definitions, i.e. a syntax definition it refers to is missed in dictionaries.
This PR adds new 2 types of examination:
- every syntax definition can be parsed using CSS Units and Values rules (CSSTree is using as a parser);
- all parsed syntax definitions has no broken references (i.e.
<type>and<'property'>), i.e. refer to existing definitions only.
The new checking rules found issues (there are connectivity issues only, because parse errors are ignored in some cases, see bellow):
Check CSS syntax connectivity...
css/at-rules.json "@document" prelude used missed syntax definition <url>
css/at-rules.json "@font-face/src" used missed syntax definition <url>
css/at-rules.json "@font-face/unicode-range" used missed syntax definition <unicode-range>
css/at-rules.json "@import" prelude used missed syntax definition <url>
css/at-rules.json "@import" prelude used missed syntax definition <declaration>
css/at-rules.json "@namespace" prelude used missed syntax definition <url>
css/properties.json "-moz-binding" used missed syntax definition <url>
css/properties.json "cursor" used missed syntax definition <url>
css/properties.json "cursor" used missed syntax definition <x>
css/properties.json "cursor" used missed syntax definition <y>
css/properties.json "offset-path" used missed syntax definition <url>
css/selectors.json ":has" used missed syntax definition <forgiving-relative-selector-list>
css/selectors.json ":is" used missed syntax definition <forgiving-selector-list>
css/selectors.json ":lang" used missed syntax definition <language-code>
css/selectors.json "::cue" used missed syntax definition <selector>
css/selectors.json "::cue-region" used missed syntax definition <selector>
css/syntaxes.json "attr()" used missed syntax definition <attr-name>
css/syntaxes.json "attr()" used missed syntax definition <attr-fallback>
css/syntaxes.json "clip-source" used missed syntax definition <url>
css/syntaxes.json "filter-function-list" used missed syntax definition <url>
css/syntaxes.json "image" used missed syntax definition <url>
css/syntaxes.json "image-src" used missed syntax definition <url>
css/syntaxes.json "keyframe-block" used missed syntax definition <declaration-list>
css/syntaxes.json "mask-source" used missed syntax definition <url>
css/syntaxes.json "page-body" used missed syntax definition <declaration>
css/syntaxes.json "page-margin-box" used missed syntax definition <declaration-list>
css/syntaxes.json "round()" used missed syntax definition <rounding-strategy>
css/syntaxes.json "shape" used missed syntax definition <top>
css/syntaxes.json "shape" used missed syntax definition <right>
css/syntaxes.json "shape" used missed syntax definition <bottom>
css/syntaxes.json "shape" used missed syntax definition <left>
css/syntaxes.json "supports-decl" used missed syntax definition <declaration>
css/syntaxes.json "target-counter()" used missed syntax definition <url>
css/syntaxes.json "target-counters()" used missed syntax definition <url>
css/syntaxes.json "target-text()" used missed syntax definition <url>
These issues were addressed in the PR as well:
- Added missed definitions:
<attr-name>,<attr-fallback>,<rounding-strategy>,<url>,<url-mofdifier>,<declaration>,<declaration-list>,<forgiving-relative-selector-list>,<forgiving-selector-list> - Renamed
<unicode-range>into<urange>(see The Unicode-Range microsyntax and a record in change log) - Replaced
<language-code>for[ <string> | <ident> ]since there is no a definition forlanguage-codeanywhere in the CSS specs, but a prose for:lang()claims that a value should beidentorstring. - Replaced
<selector>(used for::cue/::cue()) for<compound-selector>, since there is no<selector>definition (a "selector" meaning depends on context of use), but<compound-selector>looks pretty close to what is described in the spec. - Changed a part of
cursorproperty syntax:<x> <y>-><number> <number>, since there is no definitions forxandy. I think that that's an artefact of the legacy, because it's a pretty old definition and all other definitions have no such precision in a syntax part naming. Except forshape()(see below). - Changed a definition for
<shape>which is using for deprecatedclipproperty. So, the same here, it's an artefact of legacy. The syntax was extended to allow parameters with no comma, andshapedefinition was renamed intorect()according to the spec.
Some exceptions was added to the lint script, to avoid parse error warnings for now:
@charsetat-rule: syntax should be@charset <string>(current syntax has no parse error, but can't be used for a syntax matching since incorrect)ID selectors: syntax should be"#" <ident>Universal selectors: syntax should be"*"Adjacent sibling combinator: syntax should be"+"::after,::before,::first-letterand::first-line
All these exceptions can (should) be eliminated, but it should be discussed. The only reason these things have an invalid syntax that's more readable for humans when displaying on MDN. However, looks like currently mdn/data is not used for MDN, therefore may be no reason for such deviations from the specs now.
<rounding-strategy> added in #605.
Now it reports 5 new issues:
css/at-rules.json "@font-palette-values" prelude used missed syntax definition <dashed-ident>
css/at-rules.json "@font-palette-values/override-colors" used missed syntax definition <absolute-color-base>
css/properties.json "animation-composition" used missed syntax definition <single-animation-composition>
css/properties.json "font-palette" used missed syntax definition <palette-identifier>
css/syntaxes.json "ray()" used missed syntax definition <ray-size>
@teoli2003 Could you please comment on PR?
Sorry, I missed this one.
We want to retire this repository, so we prefer not to add non-data features.
If you are using it and need help getting rid of it (by using w3c/webref) we would happily be available for a discussion. If your use case is not covered by w3c/webref, we would be happy to know about it.