开发者

JSDoc support in IntelliJ IDEA

开发者 https://www.devze.com 2023-01-23 04:18 出处:网络
Is there documentation for what JSDoc subset, superset, or mix of the two IntelliJ supports? My motivation for using JSDoc is two-fold:

Is there documentation for what JSDoc subset, superset, or mix of the two IntelliJ supports? My motivation for using JSDoc is two-fold:

  1. For developers: so IntelliJ can provide better code-completion, code checkin开发者_Go百科g, error checking, etc.
  2. 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消