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,

  1. Documentation for first function is not displayed.
  2. Workshop namespace IS created
  3. Workshop.doIt is documented only by its description, arguments are not
  4. 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,

  1. Documentation for first function is not displayed.
  2. Workshop namespace IS created
  3. Workshop.doIt is documented only by its description, arguments are not
  4. 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 badges
Add a ment  | 

3 Answers 3

Reset to default 4

Here'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