2013-12-18 18 views
0

我使用John Resig的Class extend來構建一組組件,我使用JsDoc爲它們創建文檔。當我創建這樣的「類」時:JsDoc使我的課加倍

/** 
* Tests a thing to see what it is, baby 
* @param {string=}Id the Id babyyyy 
* @constructor 
*/ 
TestThing = function(Id){ 
    /** 
    * The thing's id 
    * @type {string=} 
    */ 
    this.Id = Id; 
} 

/** 
* Gets the thing 
* @param {number} id 
* @returns {number} 
* @memberof TestThing 
*/ 
TestThing.prototype.Get = function(id){ 
    return 5; 
} 

JsDoc按預期工作,在文檔中創建一個類。

當我用約翰的擴展創建一個:

/** 
* Tests a thing to see what it is, baby 
* @constructor 
    */ 
TestThing2 = Class.extend({ 

    /** 
     * Creates another thing 
     * @constructs TestThing2 
     * @param {number} id 
     */ 
    init: function(id) { 
     /** 
      * The thing's id 
      * @type {string=} 
      */ 
     this.Id = id; 
    }, 

    /** 
     * Gets the thing 
     * @param {number} id 
     * @returns {number} 
     * @memberof TestThing2 
     */ 
    Get: function(id) { 
     return 5 
    } 
}) 

我得到的文檔與在同一頁上2個版本之類的,第一個沒有構造函數的參數(所以新TestThing2())和(new TestThing2(id))。

顯然我不想要兩個版本的文檔,特別是當第一個版本是「錯誤的」時。我猜想我錯過了一些標籤或某些東西,但我無法弄清楚什麼。

在此先感謝。

+0

是否有任何理由放棄第二個例子中的第一個doclet是不可接受的?如果我放棄它,我會得到一些對我來說很好的東西。 – Louis

+0

@Louis,這似乎是解決方案。我想我正在混合不同的例子,我試圖遵循。謝謝! – JBalzer

+0

太棒了!我會提供一個你可以接受的答案。 – Louis

回答

2

如果您在第二個示例中刪除第一個doclet,則只會在文檔中獲得一個類,並且鏈接和文檔指向正確的位置。