我有一个包含此方法的类
/**
* 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;
}
};
它以_
为前缀,以区别于公共(public)接口(interface)的replace
方法。当前面有 _
时,为什么 JSDoc 不会记录此方法?如果我删除它,它会完美地记录它。我可以做些什么来使 JSDoc 记录此方法吗?
最佳答案
jsdoc-toolkit 假定以 _
开头的方法是私有(private)的。这确实是一个共同的约定。您可以看到通过使用 --private
选项运行来包含该方法。
要强制将其记录为公开,请包含 @public
标记。
顺便说一句,您不需要使用@name
,大多数情况下会自动检测函数的名称。
关于javascript - 如何让 JSDoc 记录我的 _methods?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7718529/