I've recently started using jsdoc comments for documenting our javascript code, however I'm finding conflicting examples of the usage of the @param tag.
See https://code.google.com/p/jsdoc-toolkit/wiki/TagParam (PascalCase)
and https://developers.google.com/closure/compiler/docs/js-for-compiler (camel/lowercase).
camelCase makes sense to me since:
var foo = 1;
console.log(typeof foo); // outputs "number"
What's the correct casing to use for jsDoc @param comments? Or does it not matter? I'm planning to use it for document generation as well as running the code through google closure to get type checking.
Thanks!
JSDoc comments should generally be placed immediately before the code being documented. Each comment must start with a /** sequence in order to be recognized by the JSDoc parser. Comments beginning with /* , /*** , or more than 3 stars will be ignored.
If a parameter is expected to have a specific property, you can document that property by providing an additional @param tag. For example, if an employee parameter is expected to have name and department properties, you can document it as follows: /** * Assign the project to a list of employees.
JSDoc tagsSpecifies the type of the object to which the keyword this refers within a function.
Press Ctrl+Shift+O for viewing all the methods and corresponding JSDoc opens up when you select a method there and hover over the method.
The conflicting examples for JSDoc type expressions involve the JavaScript primitive types string
, number
and boolean
, which have corresponding wrapper types: String
, Number
, and Boolean
.
From Closure: The Definitive Guide:
The use of wrapper types is prohibited in the Closure Library, as some functions may not behave correctly if wrapper types are used where primitive types are expected.
See MDN: Distinction between string primitives and String objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With