Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jsdoc3 commenting object

Assuming I have some object, what the is way to comment it using jsdoc3?

/**
 * Test object
 * @namespace test
 */
var test = {
    /**
     * Some defaults
     * @memberOf test
     */
    defaults: {
      'test1': 1,
      'test2': 2
    },
    /**
     * Somthing else
     * @memberOf test
     */
    deep: {
      /**
       * Some option
       * @memberOf {test.deep}
       */
      option: {},
      /**
       * Some method
       * @memberOf test.deep
       */
      method: {},
      /**
       * Some option
       * @memberOf {test.deep.evenMore}
       */
      evenMore: {
        /**
         * Some option
         * @memberOf test.deep.evenMore
         */
        test: false
      }
    }
};

But jsdoc creates documentation only for Namespace: test and members deep, defaults

Namespace: test test Test object

Members

deep Somthing else

defaults Some defaults

like image 270
Max Avatar asked Feb 14 '14 14:02

Max


People also ask

How do I make comments in JSDoc?

JSDoc comments should generally be placed immediately before the code being documented. Each comment must start with a /** sequence in order to be recognized by the JSDoc parser. Comments beginning with /* , /*** , or more than 3 stars will be ignored.

What is @param in comments?

The @param tag provides the name, type, and description of a function parameter. The @param tag requires you to specify the name of the parameter you are documenting. You can also include the parameter's type, enclosed in curly brackets, and a description of the parameter.

How do I view a JSDoc file?

Press Ctrl+Shift+O for viewing all the methods and corresponding JSDoc opens up when you select a method there and hover over the method.

Why should I use JSDoc?

JsDoc provides two types of tags: block tags and inline tags. Block tags provide means to annotate variables, functions, arguments, modules, namespaces, return types, and classes and describe what a specific code snippet does. These could be types, arguments, callbacks, modules, namespaces, etc.


1 Answers

As @Scottux said, the only way to archieve this is naming additional namespaces.

/**
 * Test object
 * @namespace test
 */
var test = {
    /**
     * Some defaults
     * @memberOf test
     */
    defaults: {
      'test1': 1,
      'test2': 2
    },
    /**
     * Somthing else
     * @memberOf test
     * @namespace test.deep
     */
    deep: {
      /**
       * Some option
       * @memberOf test.deep
       */
      option: {},
      /**
       * Some method
       * @memberOf test.deep
       */
      method: {},
      /**
       * Some option
       * @memberOf test.deep
       * @namespace test.deep.evenMore
       */
      evenMore: {
        /**
         * Some option
         * @memberOf test.deep.evenMore
         */
        test: false
      }
    }
};

The generated documentation will look like this:


Generated documentation screenshot

like image 129
rpax Avatar answered Nov 02 '22 12:11

rpax