admin管理员组文章数量:1415637
I'd like to know how can I define two signatures for the constructor with 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 () {
}
});
This produces one constructor with {string} p1.
Thanks for your help
I'd like to know how can I define two signatures for the constructor with 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 () {
}
});
This produces one constructor with {string} p1.
Thanks for your help
Share Improve this question edited May 16, 2012 at 9:50 János Roden asked May 16, 2012 at 9:17 János RodenJános Roden 1681 silver badge11 bronze badges2 Answers
Reset to default 5DocumentJS, the documentation tool used/created by the JavascriptMVC project has released a new "@signature" annotation that allows you to annotate multiple signatures for the same method.
I can't find much documentation but according to the source (edited for brevity) it looks straight forward:
/**
* @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 ) {
JSDoc doesn't have a concept parable to the Visual Studio XML Doc multiple signatures. One option would be to document parameters as having multiple possible types, and marking some optional.
/**
* @param {Number|Object} arg Description of arg
* @param {Number} [arg2] Description of arg2
*/
本文标签: javascriptDocument constructor with multiple signaturesStack Overflow
版权声明:本文标题:javascript - Document constructor with multiple signatures - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745242723a2649414.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论