JSDoc不解析以逗号

时间:2015-07-31 21:45:51

标签: javascript jsdoc

我正在使用以下test.js文件尝试JSDoc和Docco:

/**
 * @fileOverview Various tool functions.
 * @author <a href="mailto:jd@example.com">John Doe</a>
 * @version 3.1.2
 */

/** @namespace util */
var util = {

  // ## Multiply ##
  // with this function you can make amazing multiplications!

  /**
   * Multiplies two numbers
   * @param {int} a - a number
   * @param {int} b - another number
   * @returns {int}
   * @example
   * var m = util.multiply(2, 3); // 6
   */

  multiply: function (a, b){
    return a * b;
  }

  // ## Divide ##
  // with this function you can divide two numbers

  /**
   * Divides two numbers.
   * @param {int} a - a number
   * @param {int} b - another number
   * @returns {int} a/b
   */

, divide: function (a, b) {
    // note that if the numbers are not divisible, the result will be a float.
    return a / b;
  }
};

Docco正确输出文档(两个函数都出现),但JSDoc只输出一个,如下面的屏幕截图所示:

Docco:

Docco printscreen

JSDoc:

JSDoc printscreen

为何会出现这种情况的想法?

2 个答案:

答案 0 :(得分:1)

似乎问题是comma first style。自2013年以来,有一个错误:https://github.com/jsdoc3/jsdoc/issues/446

如果我使用divide函数从行的开头删除逗号并在multiply函数的右大括号之后添加它,则JSDoc会正确生成文档:

JSDoc printscreen

修改:添加GitHub问题链接。

答案 1 :(得分:1)

我创建了一个JSDoc插件来支持逗号的第一个样式: https://github.com/Booster2ooo/jsdoc-comma-first

我希望它有所帮助。