-
Notifications
You must be signed in to change notification settings - Fork 24
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
Export CSS properties and values into reffy-reports #113
Comments
@dontcallmedom and I added support for the extraction of CSS property definitions in Reffy a few weeks ago. I had not noticed the discussion on a possible Reffy now has a CSS grammar parser. Now, while it's easy to extract all properties, some value definitions cannot be parsed. See #110 for a list of issues we bumped into, and w3c/csswg-drafts#2921 where we wondered about possible improvements to the Value Syntax Definition. The result of the parsing appears in the
The content is mostly a direct copy-and-paste of how things are defined in CSS specs, with a couple of conventions of our own (notably the We did not add the
In short, yes, we can easily add a |
That's great, thanks @tidoust! Is there something we could use to parse those |
The CSS grammar parser can parse the right-hand side of equations in these files. But rather than extending it to support complete parsing of that file, I'm wondering if we shouldn't rather dump a JSON structure similar to the one created during the crawl. The textual dump was an attempt to create an IDL-like format that could then get used in CSS specs, but I'm not clear that's a good goal at all:
The crawler creates the following structure (here for CSS Animations): {
"properties": {
"animation-composition": {
"Name": "animation-composition",
"Value": "<single-animation-composition>#",
"Initial": "replace",
"Applies to": "all elements, ::before and ::after pseudo-elements",
"Inherited": "none",
"Percentages": "N/A",
"Computed value": "As specified",
"Canonical order": "per grammar",
"Animatable": "no"
}
},
"descriptors": {},
"valuespaces": {
"<single-animation-composition>": {
"Value": "replace | add | accumulate"
}
}
} I propose to dump that structure to a JSON file instead of creating The CSS grammar parser can be applied to The result of parsing the {
"type": "array",
"items": {
"type": "valuespace",
"name": "single-animation-composition"
},
"separator": ","
} See What about it? |
I think the most basic test we could generate is one that simply checks for property support using Second easiest would be to test using To test the initial values sounds tricky because they'd be affected by UA style sheets. |
Following discussions in #113, this update dumps the extracted CSS definitions as JSON files (as opposed to `.cvds` files) in the `css` folder. The JSON file is a JSON object with `properties`, `descriptors` and `valuespaces` properties that list the definitions extracted. A typical example: ```json { "properties": { "animation-timeline": { "name": "animation-timeline", "value": "<single-animation-timeline>#", "initial": "auto", "appliesTo": "all elements, ::before and ::after pseudo-elements", "inherited": "none", "percentages": "N/A", "media": "interactive", "computedValue": "As specified", "canonicalOrder": "per grammar", "animatable": "no" } }, "descriptors": {}, "valuespaces": { "<single-animation-timeline>": { "value": "auto | scroll([element(<id-selector>)[, <scroll-direction>[, <scroll-offset>[, <scroll-offset>[, <time>[, <single-animation-fill-mode>]]]]]])" }, "<scroll-direction>": { "value": "auto | block | inline | horizontal | vertical" }, "<scroll-offset>": { "value": "<length> | <percentage> | auto" } } } ``` The update also makes sure that all properties extracted from CSS specs use a lower camel case convention. When multiple levels of a spec exists, only the contents of the latest level are dumped for now. There was a bug in the code that made it miss some cases (where the URL of the different levels did not follow the same pattern) and that could create file writing conflicts. This should now have been fixed. Also, the logic that creates CSS and IDL dumps has been separated to dump the latest level that actually has some related definitions (for instance CSS Animations Level 2 is currently a delta spec and does not define any IDL, whereas the first level does). Whether we'll want to keep that behavior later on for such delta specs is an open question.
Following discussions in #113, this update dumps the extracted CSS definitions as JSON files (as opposed to `.cvds` files) in the `css` folder. The JSON file is a JSON object with `properties`, `descriptors` and `valuespaces` properties that list the definitions extracted. A typical example: ```json { "properties": { "animation-timeline": { "name": "animation-timeline", "value": "<single-animation-timeline>#", "initial": "auto", "appliesTo": "all elements, ::before and ::after pseudo-elements", "inherited": "none", "percentages": "N/A", "media": "interactive", "computedValue": "As specified", "canonicalOrder": "per grammar", "animatable": "no" } }, "descriptors": {}, "valuespaces": { "<single-animation-timeline>": { "value": "auto | scroll([element(<id-selector>)[, <scroll-direction>[, <scroll-offset>[, <scroll-offset>[, <time>[, <single-animation-fill-mode>]]]]]])" }, "<scroll-direction>": { "value": "auto | block | inline | horizontal | vertical" }, "<scroll-offset>": { "value": "<length> | <percentage> | auto" } } } ``` The update also makes sure that all properties extracted from CSS specs use a lower camel case convention. When multiple levels of a spec exists, only the contents of the latest level are dumped for now. There was a bug in the code that made it miss some cases (where the URL of the different levels did not follow the same pattern) and that could create file writing conflicts. This should now have been fixed. Also, the logic that creates CSS and IDL dumps has been separated to dump the latest level that actually has some related definitions (for instance CSS Animations Level 2 is currently a delta spec and does not define any IDL, whereas the first level does). Whether we'll want to keep that behavior later on for such delta specs is an open question.
See discussion in w3c/reffy#113 The dumps follow a simple JSON structure that separates definitions of properties, descriptors and valuespaces. That structure may evolve and completely change over time, depending on needs.
@foolip Reffy now generates JSON dumps of CSS definitions, and these dumps have been added to reffy-reports: As mentioned above, Reffy's CSS grammar parser can be used to parse the The format followed by these files is entirely open to change. We don't use these files for anything for the time being and don't have any immediate plan either. Also note the problem with "delta" specs (#117): the dumps only contain the definitions of the latest level of a given spec for now, and thus only contain the delta. |
@tidoust any reason not to close this issue? |
Nope, no one has complained about the format, so let's assume it's good enough... |
https://github.com/web-platform-tests/wpt/projects/1 is progressing nicely and has been helped immensely be reffy-reports providing daily updates of IDLs from specs.
Having a machine-readable list of all CSS properties and values would facilitate creating something similar for CSS, tracking by web-platform-tests/wpt#9113.
The text was updated successfully, but these errors were encountered: