如何让 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 记录此方法吗?
I have a class which contains this method
/**
* 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;
}
};
It is prefixed with _
to distinguish it from the replace
method which is for the public interface. Why won't JSDoc document this method when it has a _
in front? If I remove it it documents it perfectly. Is there anything I can do to make JSDoc document this method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
jsdoc-toolkit 假定以
_
开头的方法是私有的。这确实是一个共同的约定。您可以看到通过使用--private
选项运行来包含该方法。要强制将其记录为公共,请包含
@public
标记。顺便说一句,您不需要使用
@name
,在大多数情况下会自动检测函数的名称。jsdoc-toolkit assumes that methods starting with
_
are private. This is indeed a common convention. You can see that the method is included by running with--private
option.To force documenting it as public, include
@public
tag.BTW, you don't need to use
@name
, the name of a function is detected automatically on most cases.