2011-10-10 41 views
2

我有包含該方法如何讓JSDoc記錄我的_methods?

/** 
* Uses the native RegExp object and the native string.replace to replace text 
* @name _replace 
* @param {String} find Text string or regex to search for 
* @param {String} replace Text string or regex for replacing 
* @param {String} string String to perfom the replace on 
* @returns {String} Returns the string with the text replaced 
*/ 
this._replace = function(find, replace, str) { 
    var regex; 

    if(typeof find !== undefined && replace !== undefined && typeof str === 'string') { 
     regex = new RegExp(find, this._getFlags()); 
     return str.replace(regex, replace, str);    
    } else { 
     return false; 
    } 

}; 

它帶有前綴_replace方法,其是用於公共接口區分它的類。爲什麼JSDoc在前面有_時不記錄這種方法?如果我刪除它,它完美的文件。有什麼我可以做JSDoc文件這個方法嗎?

回答

4

jsdoc-toolkit假設以_開頭的方法是私有的。這確實是一個常見的慣例。您可以通過運行--private選項來查看該方法。

要強制公開它的文檔,請包括@public標記。

順便說一句,您不需要使用@name,大多數情況下會自動檢測功能的名稱。

+0

非常好,謝謝。我放棄了對這個問題的迴應。不尋常的Stackoverflow的。 – MrMisterMan

相關問題