Different orders of "name" and "type" fields in @param tag permitted
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 15.5k
- Forks
- 1.5k
- Avg merge
- 10d 23h
- Merged PRs (30d)
- 1
Description
When documenting method parameters using the @param tag with a "name", "type", and "description", the jsDoc documentation examples imply that when all three of these fields are present, the "type" field should come first, followed by the "name" field, followed by the "description" (with an optional hyphen to separate the name and description):
* @param {number} paramName This is the description
OR
* @param {number} paramName - This is the description
However, jsdoc allows us to switch the order of the name and type fields:
* @param paramName {number} This is the description
No warning or error is thrown in this case, and the parser output is the same as if we'd ordered those fields in the way that the documentation suggests.
We very much prefer this order over what the documentation suggests because it is more succinct and readable. The non-hyphen style is not acceptable to us because it's not readable, which is obviously very important for documentation. The documentation suggests adding a hyphen between the "name" and "description" fields to address that problem. However, there's no need for a hyphen at all if the fields are ordered as "name", "type", "description", like this:
* @param paramName {number} This is the description
However, there is no mention of support for this style in the documentation even though, as stated earlier, the parser supports it just fine.
Therefore:
- Is the field ordering "name", "type", "description" intentionally supported?
- Should the
@paramdocumentation be updated to include this ordering as an option?
My vote is "yes".
Input code
Here's a full example:
/**
* A method that does something.
*
* @param param1 {number} This is a description of param 1
* @param param2 {number} This is a description of param 2
*/
function doSomething(param1, param2) {
return param1 + param2;
}
JSDoc configuration
Default.
Your environment
| Software | Version |
|---|---|
| JSDoc | 3.6.3 |
| Node.js | 8.10.0 |
| npm | 6.4.1 |
| Operating system | macOS 10.14.5 |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the linked JSDoc @param documentation and compare it with the supplied input code using the default configuration. Verify whether the name–type–description ordering is intentionally supported; done means documenting that ordering as an option if supported, or clarifying that it is not supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100