-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Document spec_url guidelines #29582
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
base: main
Are you sure you want to change the base?
Document spec_url guidelines #29582
Changes from all commits
1486dc4
226c1b5
35b5549
dfb37d0
d35a53c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Data guidelines for the `spec_url` property | ||
|
|
||
| The browser-compat-data project (BCD) uses the `spec_url` property to map compatibility data to features described in specifications. | ||
|
|
||
| ## Benefits | ||
|
|
||
| Maintaining pointers to specifications from BCD features provides several benefits: | ||
|
|
||
| - Specifications can show compatibility data inline next to feature definitions. | ||
| - If a `spec_url` is provided, BCD itself or other data consumers, can treat the feature as standardized. In the absence of a `spec_url`, we could say that the feature is non-standard. | ||
| - By using deep links (fragment identifiers), BCD can more precisely identify the feature. This can be helpful when trying to understand descriptions of BCD feature keys, for example. | ||
| - It enables statistics and coverage analysis. Which BCD features are standardized? Which standards bodies standardize? And more. | ||
|
|
||
| ## Schema definition and validation | ||
|
|
||
| The `spec_url` property is defined and validated by the BCD JSON schema: It may be either a single URL or an array of URLs, each pointing to a specific part of a specification where the feature is defined. | ||
|
|
||
| The `spec_url` property is required if `standard_track` is set to `true`. However, currently, there is an [exception list](https://github.com/mdn/browser-compat-data/blob/main/lint/common/standard-track-exceptions.txt) for this requirement. BCD maintainers are working through this backlog. It updates automatically when you add a URL to a feature that doesn't currently have a `spec_url` property. | ||
|
|
||
| Each URL must link to a specification published by a standards body or a formal proposal that may lead to such publication. | ||
| To determine whether a specification host is valid, BCD relies on data from the [w3c/browser-specs](https://github.com/w3c/browser-specs) project. | ||
|
|
||
| If a specification is listed in browser-specs and has a [standing](https://github.com/w3c/browser-specs#standing) of "good", the URL will be accepted in BCD's `spec_url` field. | ||
|
|
||
| If BCD's linter complains about the provided URL, you will need to check its state within browser-specs. Common scenarios include: | ||
|
|
||
| - The specification is not yet part of browser-specs. Check whether an issue already exists; if not, open one and ask whether the W3C would consider adding the specification. | ||
| - The specification no longer has a "good" standing. Check if there is a new version of the specification (at a different URL), or if the specification development has been discontinued (and the features in BCD should be considered "non-standard" from this point on). | ||
| - If the specification cannot be added to browser-specs, but there is a reason it should be in BCD, you can add it to BCD's [specification host exception list](https://github.com/mdn/browser-compat-data/blob/main/lint/common/spec-urls-exceptions.txt). Only do this as a last resort. The specifications hosted at https://github.com/WebAssembly and https://registry.khronos.org/webgl/extensions/ are part of the exception list by default. | ||
| - The specification URL doesn't contain a fragment identifier. You will have to add one. It looks like this: `https://tc39.es/proposal-promise-allSettled/#sec-promise.allsettled`. | ||
|
|
||
| ## Best practices | ||
|
|
||
| In addition to the validated rules above, the following best practices have emerged. | ||
|
|
||
| ### Aim to provide just one URL | ||
|
|
||
| The `spec_url` property allows to take an array of multiple URLs, however, as a general guiding principle, provide just the single most meaningful URL. For example, don't add multiple (historical) versions of specifications. | ||
|
|
||
| If you find yourself in a situation where your BCD (behavioral) feature points to several URLs of a specification, this could actually be a strong hint that you should split up the feature into multiple BCD feature keys. | ||
|
|
||
| See below for cases where we actually recommend multiple URLs (events and specifications extending other specifications). | ||
|
|
||
| ### Events | ||
|
|
||
| For events, provide two URLs: one for the `.onevent` property definition, and one for the event itself. | ||
|
|
||
| ```json | ||
| "spec_url": [ | ||
| "https://drafts.csswg.org/web-animations-1/#dom-animation-oncancel", | ||
| "https://drafts.csswg.org/web-animations-1/#cancel-event" | ||
| ], | ||
| ``` | ||
|
|
||
| ### Specifications extending other specifications | ||
|
|
||
| When a specification extends the definition of another specification, it makes sense to list both as `spec_urls`. For example: | ||
|
|
||
| - ECMA 262 is extended by ECMA 402 | ||
| - https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-date.prototype.tolocaledatestring | ||
| - https://tc39.es/ecma402/#sup-date.prototype.tolocaledatestring | ||
| - SVG and CSS both define a property | ||
| - https://drafts.csswg.org/css-inline/#baseline-shift-property | ||
| - https://w3c.github.io/svgwg/svg2-draft/text.html#BaselineShiftProperty | ||
| - API interfaces which have a core definition and and extended in other specifications. | ||
| - CSS properties which an initial definition in one level of a spec, and are completed in a subsequent diff spec. | ||
|
|
||
| ### Maplikes, Setlikes, Iterables | ||
|
|
||
| When the interface has "entries", "forEach", "get", "has", "keys", "values", "@@iterator" methods and a "size" getter via "maplike", "setlike", or "iterable" IDL constructs, link to the interface containing the definition and not to the IDL standard. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have argued before that referencing the IDL construct or the method defined by the construct would make it easier to identify in the BCD data where this feature comes from. Using two spec URLs, one pointing to the interface, and the other pointing to the specification of the construct member would provide clarity. Alternatively, we could capture this in a separate internal (?) field.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I understand the benefit you're after. The second URL would always point to the same spot in the IDL standard? If we want to somehow capture that these things are of type |
||
|
|
||
| ```json | ||
| 👍 "spec_url": "https://webaudio.github.io/web-audio-api/#audioparammap", | ||
|
|
||
| 👍 "spec_url": "https://drafts.css-houdini.org/css-typed-om/#cssnumericarray", | ||
|
|
||
| 👎 "spec_url": "https://webidl.spec.whatwg.org/#dfn-maplike", | ||
|
|
||
| 👎 "spec_url": "https://webidl.spec.whatwg.org/#dfn-iterable", | ||
| ``` | ||
|
|
||
| ### WebIDL flags | ||
|
|
||
| WebIDL flags can map to certain BCD feature keys: | ||
|
|
||
| - `[SecureContext]` uses `secure_context_required` | ||
| - `[Exposed=Worker]` (and similar) use `worker_support` | ||
|
|
||
| WebIDL flags belong to specific WebIDL features, like an interface or a method. The specifications offer no direct link to flag definitions, therefore the specification URL used for the feature itself should be used. | ||
|
|
||
| For example, if the `[SecureContext]` flag appears in front of an WebIDL interface definition, the `spec_url` for the `secure_context_required` feature is the same as the interface's `spec_url`. | ||
|
|
||
| ```json | ||
| "secure_context_required": { | ||
| "__compat": { | ||
| "description": "Secure context required", | ||
| "spec_url": "https://w3c.github.io/battery/#the-batterymanager-interface", | ||
| ``` | ||
|
|
||
| If the `[SecureContext]` flag appears in front of an WebIDL method definition, use the `spec_url` for the method. | ||
|
|
||
| ```json | ||
| "secure_context_required": { | ||
| "__compat": { | ||
| "description": "Secure context required", | ||
| "spec_url": "https://wicg.github.io/ua-client-hints/#dom-navigatorua-useragentdata", | ||
| ``` | ||
Uh oh!
There was an error while loading. Please reload this page.