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,
Does anyone know why?
Thanks!
The @namespace tag indicates that an object creates a namespace for its members. You can also write a virtual JSDoc comment that defines a namespace used by your code. If a namespace is defined by a symbol other than an object literal, you can include a type expression along with the @namespace tag.
JSDoc is a markup language used to annotate JavaScript source code files. Using comments containing JSDoc, programmers can add documentation describing the application programming interface of the code they're creating.
Here's why:
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 outcome below
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With