admin管理员组文章数量:1356304
I'm editing a js file with JsDoc to get a clean documentation. My structure is quite simple:
/**
* Finds an object
* @param {string} prop - Property
*/
Array.prototype.findObject = function _findObj(prop, val){
// blablabla
}
function myfunc(plep){
// does something
}
/**
* Workshop Namespace
* @namespace
*/
var Workshop = {};
/**
* Does something great
* @param {*} plep - My super param!
*/
Workshop.doIt = myfunc;
/**
* It works!
* @param {string} fly - my flying param
*/
Workshop.flyNow = function _flyN (fly){
// fly!
}
However,
- Documentation for first function is not displayed.
- Workshop namespace IS created
- Workshop.doIt is documented only by its description, arguments are not
- Workshop.flyNow is well documented
Does anyone know why?
Thanks!
I'm editing a js file with JsDoc to get a clean documentation. My structure is quite simple:
/**
* Finds an object
* @param {string} prop - Property
*/
Array.prototype.findObject = function _findObj(prop, val){
// blablabla
}
function myfunc(plep){
// does something
}
/**
* Workshop Namespace
* @namespace
*/
var Workshop = {};
/**
* Does something great
* @param {*} plep - My super param!
*/
Workshop.doIt = myfunc;
/**
* It works!
* @param {string} fly - my flying param
*/
Workshop.flyNow = function _flyN (fly){
// fly!
}
However,
- Documentation for first function is not displayed.
- Workshop namespace IS created
- Workshop.doIt is documented only by its description, arguments are not
- Workshop.flyNow is well documented
Does anyone know why?
Thanks!
Share Improve this question edited Jun 7, 2017 at 23:29 Igwe Kalu 14.9k2 gold badges30 silver badges39 bronze badges asked Dec 21, 2015 at 10:28 Jo ColinaJo Colina 1,9248 gold badges29 silver badges49 bronze badges3 Answers
Reset to default 4Here's why:
1.
First function is not documented because it does not belong to any recognisable namespace. To fix this issue, you could create a virtual namespace as follows:
/**
* @namespace Array
*/
And you can improve the documentation of the function as follows:
/**
* Finds an object.
*
* @param {string} prop Property name.
* @param {string|number|function|object} val Value.
*
* @function findObject
* @memberof Array#
*/
Array.prototype.findObject = function _findObj ( prop, val ) {
// blablabla
}
With the oute below
3.
Arguments weren't documented because the JSDoc parser does not recognise Workshop.doIt( ... )
as a function. That can be fixed with the @function
or @method
tag:
/**
* Does something great
* @param {*} plep - My super param!
*
* @method
*/
Workshop.doIt = myfunc;
And the result look like this:
Does Array
exist as symbol? If not then that is the reason this is not getting documented.
Regarding the parameter, are you sure *
is a valid type? Can you try Object
?
/**
* Finds an object
* @param {string} prop - Property
*/
Array.prototype.findObject = function _findObj(prop, val){
// blablabla
}
/**
* Does something great
* @param {*} plep - My super param!
*/
function myfunc(plep){
// does something
}
/**
* Does something great
* @param {*} plep - My super param!
* @function
*/
var alternativeDoIt = function myfunc2(plep){
// does the same thing
}
/**
* Workshop Namespace
* @namespace
*/
var Workshop = {};
/**
* Does something great 2
* @function (<== check if this is useful)
*/
Workshop.doIt = myfunc;
Workshop.doIt2 = alternativeDoIt;
/**
* It works!
* @param {string} fly - my flying param
*/
Workshop.flyNow = function _flyN (fly){
// fly!
}
本文标签: javascriptJsDoc NamespaceStack Overflow
版权声明:本文标题:javascript - JsDoc Namespace - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744011231a2575603.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论