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

Adding subfeatures guidance #17352

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions docs/data-guidelines/features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Data guidelines for when to add features

This file contains specific guidelines on when to add features to BCD, and the various types of features tracked in BCD.

## Glossary

- Feature: some trackable feature supported in a browser or runtime
- Subfeature: any feature whose support is directly dependent on a parent (for example, the property of an interface)
- Top-level feature: a feature that lives at the top of a category (for example, an interface, a CSS property, etc.)
- Behavioral feature: a feature that describes the behavior of the browser or runtime (for example, security requirements, sorting, worker support, etc.)
- Parameter feature: a feature that describes the support for a return type, method parameter, property value, etc.

## Adding features and subfeatures

A JSON file should be created for every _top level feature_ that has support in any of the browsers or runtimes tracked in BCD. For Web APIs, the top level features are individual Web API interfaces.

A possible structure for a Web API is shown below:

```
category // category name (always `api` for API interfaces)
interface // top level feature
properties // subfeature, add if supported
property values // parameter subfeature, add all of them if not all values were supported since property was introduced
methods // subfeature, add if supported
parameters // parameter subfeature, add all of them if not all parameters were supported since method was introduced
parameter options // parameter subfeature, add all of them if not all parameter options were supported since property was introduced
parameter type // parameter subfeature, add all of them if not all parameter types were supported since property was introduced
support in workers // behavioral subfeature, add if compatibility is different (might also just be on specific methods)
```
Comment on lines +19 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ca we use nested lists here, rather than a code block?

Suggested change
```
category // category name (always `api` for API interfaces)
interface // top level feature
properties // subfeature, add if supported
property values // parameter subfeature, add all of them if not all values were supported since property was introduced
methods // subfeature, add if supported
parameters // parameter subfeature, add all of them if not all parameters were supported since method was introduced
parameter options // parameter subfeature, add all of them if not all parameter options were supported since property was introduced
parameter type // parameter subfeature, add all of them if not all parameter types were supported since property was introduced
support in workers // behavioral subfeature, add if compatibility is different (might also just be on specific methods)
```
- _category_ ← category name (always `api` for API interfaces)
- _interface_ ← top-level feature
- _properties_ ← subfeature, add if supported
- _property values_ ← parameter subfeature, add all of them if not all values were supported since property was introduced
- _methods_ ← subfeature, add if supported
- _parameters_ ← parameter subfeature, add all of them if not all parameters were supported since method was introduced
- _parameter options_ ← parameter subfeature, add all of them if not all parameter options were supported since property was introduced
- _parameter type_ ← parameter subfeature, add all of them if not all parameter types were supported since property was introduced
- _worker support_ ← behavioral subfeature, add if compatibility is different (might also just be on specific methods)


The interface must include subfeatures for _all_ its properties and methods that have an implementation in at least one of the supported browsers, whether or not they were added at the same time as the parent interface.

All other code and behavioral aspects of the interface are given nested nodes **only** if their compatibility is _different_ to that of their parent feature. This applies to method arguments, method argument options, and behavior changes like the addition of support for workers, or the type of return value.

> [!TIP]
> A good rule of thumb is that if a behavioral subfeature has the same compatibility information as its parent, then the subfeature is not needed.
> Another good rule of thumb is that if the signature of a method changes to introduce new parameters, then all parameters should be documented.

Here is an example scenario:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep it simple:

Suggested change
Here is an example scenario:
Example:


- An interface is defined in a specification with a method that has two parameters.
- A supported browser implements the method and both the parameters:
- A feature node is created for the method (by default)
- Subfeature nodes are not created for the method parameters because they were created in the same version as the methods; there is no compatibility change.
- Another browser implements the methods, but only one of the parameters.
- A subfeature node is added to the method parameter that was supported by _both_ browsers.
- Another subfeature node is added to the method parameter that was _not_ supported by the second browser.
- Yet another browser implements the method with a new parameter.
- A method subfeature is added for the new parameter because it was added in a different version than the parent method.
- The browser changes to require that the interface now can be used in workers:

- A "supported in workers" subfeature is added to the interface feature because this is a change in compatibility.
Comment on lines +41 to +52
Copy link
Contributor

@caugner caugner Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's how I would restructure the example for better readability:

Suggested change
- An interface is defined in a specification with a method that has two parameters.
- A supported browser implements the method and both the parameters:
- A feature node is created for the method (by default)
- Subfeature nodes are not created for the method parameters because they were created in the same version as the methods; there is no compatibility change.
- Another browser implements the methods, but only one of the parameters.
- A subfeature node is added to the method parameter that was supported by _both_ browsers.
- Another subfeature node is added to the method parameter that was _not_ supported by the second browser.
- Yet another browser implements the method with a new parameter.
- A method subfeature is added for the new parameter because it was added in a different version than the parent method.
- The browser changes to require that the interface now can be used in workers:
- A "supported in workers" subfeature is added to the interface feature because this is a change in compatibility.
Given: A specification defines an interface with a method that has two parameters.
Assume: One supported browser implements the method and both the parameters.
Then:
- We create a feature node for the method (by default)
- We don't create subfeature nodes for the method parameters, because they were created in the same version as the methods; there is no compatibility change.
Assume: Another browser implements the method, but only one of the parameters.
Then:
- We add one subfeature node for the parameter that is supported by _both_ browsers.
- We add another subfeature node for the parameter that is only supported by the first, but _not_ by the second browser.
Assume: Yet another browser implements the method with a new parameter.
Then:
- We add yet another subfeature node for the new parameter, because it was added in a different version than the parent method.
Assume: One of the browsers starts supporting the interface in workers:
Then:
- We add a `worker_support` subfeature (`"Available in workers"`) to the interface (see [Web Workers](./api.md#web-workers-worker_support)).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caugner I have no problem with this alternative approach, but I think I'd like the change the rule, not that I've been around a while.

The "rule" for API properties and methods is that you always add entries for all that are supported.

The current rule for method arguments (as I understand it and stated there) is that you only document the incompatibility. So the assumption is that if something is not documented then it is compatible.

I'd like to change the rule to "As soon as there is an incompatibility you should document all parameters including those that were in the original version.

The reason is that as it is now there is no way to spot whether something is compatible or has just been omitted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upshot, if we know the rules I'm open to any presentation at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this PR explains the rule different than the current status quo, then let's document the status quo first, and then propose the change afterwards. That way we separate concerns and make it easier to move forward.

Anyways, I'll put this on the agenda for the next BCD call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I wrote it to "test" the rules. So right now it reflects what I think the rules were, but not necessarily what they are.


> [!NOTE]
> If all browsers implemented worker support in their first implementation, then no subfeature would be required. It is only when any browser does something different that the subfeature is required.
1 change: 1 addition & 0 deletions docs/data-guidelines/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This file contains general guidelines that apply to all features added to BCD. F

- [API](./api.md)
- [Browsers](./browsers.md)
- [Adding new features](./features.md)
- [Tagging BCD features](./tags.md)

## Choosing a version number
Expand Down