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

Add a guideline for naming argument features #10509

Merged
merged 4 commits into from
May 19, 2021

Conversation

ddbeck
Copy link
Collaborator

@ddbeck ddbeck commented May 17, 2021

This was inspired by #9503 (comment) and a general observation that there's no real consensus about how to represent argument parameter and argument parameter objects in BCD. I'm proposing a guideline that addresses this, at least going forward. I'll add a self-review to highlight a couple of details about this.

@github-actions github-actions bot added the docs ✍️ Issues or pull requests regarding the documentation of this project. label May 17, 2021

Sometimes it's useful to represent support for specific arguments of a function or method, as a subfeature of the function itself. To record data about whether a specific argument (parameter) is supported by a function or method, use the following naming conventions:

- For named arguments, use a subfeature named `argname_argument` with description text `<code>argname</code> argument`. Where _argname_ is the name of the argument as it appears on the corresponding function's MDN page (or specification, if no MDN page is available).
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the most common practice right now is to name the feature after the argument alone (e.g., for hello(firstName, familyName), the feature would be firstName). I was inspired to follow a cue from the _event features here, but I'm not committed to it. (I do think that we should adopt a common description text though.)


- For unnamed arguments, use a subfeature named `ordinal_argument` with description text `ordinal argument` where _ordinal_ is the ordinal number position of the argument.

For example, to represent support for the second argument of a method `count()`, use a subfeature of `count` named `second_argument` and description text `Second argument`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm banking on there being no cases with four arguments. With only three, the lexical sort is fine. With four, it's unordered chaos.


For example, to represent support for the second argument of a method `count()`, use a subfeature of `count` named `second_argument` and description text `Second argument`.

- For properties of argument objects, use a subfeature named `argname_prop_argument` with description text `<code>argname.prop</code> argument`, where _argname_ is the name of the argument object and _prop_ is the name of the property.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Again, this is a bit of a departure from current practice. I don't think do this anywhere yet, but I thought this was nice: it avoids adding an additional nesting layer and ought to sort nicely.

@Elchi3
Copy link
Member

Elchi3 commented May 18, 2021

Thanks for writing this up! I used "parameter" instead of "argument" whenever I hit this case.
See also https://stackoverflow.com/questions/1788923/parameter-vs-argument.

@ddbeck
Copy link
Collaborator Author

ddbeck commented May 18, 2021

Thanks for writing this up! I used "parameter" instead of "argument" whenever I hit this case.

Ah, right. That's consistent with API reference pages too. I'll update this.

Copy link
Member

@Elchi3 Elchi3 left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs ✍️ Issues or pull requests regarding the documentation of this project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants