Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the correct casing to use for jsDoc comments?

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!

like image 295
magritte Avatar asked Mar 19 '13 12:03

magritte


People also ask

How do you write comments in JSDoc?

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.

How do you document an object in JSDoc?

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.

What are JSDoc tags?

JSDoc tagsSpecifies the type of the object to which the keyword this refers within a function.

How do I view a JSDoc file?

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.


1 Answers

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.

like image 84
Christopher Peisert Avatar answered Sep 29 '22 21:09

Christopher Peisert