JSDoc support in IntelliJ IDEA
Is there documentation for what JSDoc subset, superset, or mix of the two IntelliJ supports? My motivation for using JSDoc is two-fold:
- For developers: so IntelliJ can provide better code-completion, code checkin开发者_Go百科g, error checking, etc.
- For runtime efficiency: using the Closure compiler.
For #1 above, it is important for me to use JSDoc markup that is supported by IntelliJ, and until now figuring this out has mostly been a trial and error process.
Based on what little information is available in the WebStorm documentation, it looks like IntelliJ IDEA supports the entire JSDoc set. The only other note in the documentation is on viewing inline documentation which only points at the JSDoc SourceForge page.
It's been a bit trial and error, but I have finally been able to get decent results with it. I had especially trouble with getting inheritance for Backbone similar OO to work right. What I ended up doing was things like this:
/**
* @class App.Views.ProductView
* @extends App.Views.TemplateView
**/
App.Views.ProductView = App.Views.TemplateView.extend(
/** @lends App.Views.ProductView **/
{
/**
* @param {string} str
* @return string[]
**/
method: function (str) {
return [str, str];
}
};
You definitely have to help out a lot manually when inheritance is involved.
As far as I can tell, discrepancies were: you have to provide a name to @class, else it gets confused. @name seems to not work really well. The rest is decent, some of the tags are unused (@event, etc...).
The JSDoc support by IDEA / WebStorm is a standard feature nowadays, but with some IDE tuning it's possible to generate a JSDoc with one click.
The step-by-step guide how to enable a JSDoc generation in IDEA / WebStorm with the jsdoc
npm module:
How to generate JSDoc documentation in IntelliJ IDEA / WebStorm?
精彩评论