2012-05-16 40 views
3

文件的構造,我想知道我怎麼可以定義兩個簽名與jsdoc構造:與多個簽名

makeClass("Person", 
/** @lends Person */ 
{ 
    /** 
     @constructs 
     @param {int} p1 
    */ 
    /** 
     @constructs 
     @param {string} p1 
    */ 
    constructor: function() { 

    }, 

    /** 
     @name Person.prototype.func 
     @function 
     @param {object} arg arg desc 
    */ 
    /** 
     @name Person.prototype.func^2 
     @function 
     @param {int} arg arg desc 
     @param {int} arg2 arg2 desc 
    */ 
    func: function() { 

    } 
}); 

這就產生一個構造函數{string}裏P1。

感謝您的幫助

回答

4

JSDoc不具有可比性到Visual Studio XML文檔的多個簽名的概念。一種選擇是將參數記錄爲具有多種可能的類型,並標記一些可選的參數。

/** 
* @param {Number|Object} arg Description of arg 
* @param {Number} [arg2] Description of arg2 
*/ 
3

DocumentJS,/使用的文檔工具由JavascriptMVC項目創造了released a new "@signature" annotation,使您可以標註多個簽名的方法相同。

我找不到太多documentation但根據source(編輯爲簡潔起見),它看起來直截了當:

/** 
    * @signature `observe.attr()` 
    * @return {Object<String, *>} an object with all the properties in this `can.Observe`. 
    * 
    * @signature `observe.attr(key)` 
    * @param {String} key the property to read 
    * @return {*} the value assigned to _key_. 
    * 
    * @signature `observe.attr(key, value)` 
    * @param {String} key the property to set 
    * @param {*} the value to assign to _key_. 
    * @return {can.Observe} this Observe, for chaining 
    */ 
    attr: function(attr, val) {