What is the preferred method of commenting javascript objects & methods
There's JSDoc
/**
* Shape is an abstract base class. It is defined simply
* to have something to inherit from for geometric
* subclasses
* @constructor
*/
function Shape(color){
this.color = color;
}
The simpler the better, comments are good, use them :)
var something = 10; // My comment
/*
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur.
*/
function bigThing() {
// ...
}
But for autogenerated doc...
/**
* Adds two numbers.
* @param {number} num1 The first number to add.
* @param {number} num2 The second number to add.
* @return {number} The result of adding num1 and num2.
*/
function bigThing() {
// ...
}
Yahoo offers YUIDoc.
It's well documented, supported by Yahoo, and is a Node.js app.
It also uses a lot of the same syntax, so not many changes would have to be made to go from one to the other.