I have a JavaScript singleton defined as:
/**
* A description here
* @class
*/
com.mydomain.ClassName = (function(){
/**
* @constructor
* @lends com.mydomain.ClassName
*/
var ClassName = function(){};
/**
* method description
* @public
* @lends com.mydomain.ClassName
*/
ClassName.prototype.method1 = function(){};
return new ClassName();
})();
No warnings are printed in verbose mode (-v), but the documentation reports only "com.mydomain.ClassName()" with "A description here" as description... how can I generate documentation for ClassName's methods too?
JSDoc's purpose is to document the API of your JavaScript application or library. It is assumed that you will want to document things like modules, namespaces, classes, methods, method parameters, and so on. JSDoc comments should generally be placed immediately before the code being documented.
JSDoc is a markup language used to annotate JavaScript source code files. Using comments containing JSDoc, programmers can add documentation describing the application programming interface of the code they're creating.
Conclusion. JSDoc makes coding in JavaScript easier, helping us to code quickly while avoiding obvious errors, just by adding some lines of optional comments in our code.
TypeScript has very rich JSDoc support, for a lot of cases you can even skip making your files . ts and just use JSDoc annotations to create a rich development environment. A JSDoc comment is a multi-line comment which starts with two stars instead of one.
I solved! :)
/**
* A description here
* @class
*/
com.mydomain.ClassName = (function(){
/**
* @constructor
* @name com.mydomain.ClassName
*/
var ClassName = function(){};
/**
* method description
* @public
* @name com.mydomain.ClassName.method1
*/
ClassName.prototype.method1 = function(){};
return new ClassName();
})();
I just replaced @lends with @name!
UPDATE: the right approach in order to have the full documentation is the following:
/**
* A description here
* @class
*/
com.mydomain.ClassName = (function(){
var ClassName = function(){};
/**
* method description
* @memberOf com.mydomain.ClassName
*/
ClassName.prototype.method1 = function(){};
return new ClassName();
})();
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