vitaly-t
vitaly-t

Reputation: 25840

Documenting a property-namespace inside a class

How to document a property-namespace inside a class?

/**
 * @constructor User
 * @param forename
 * @param surname
 */
function User(forename, surname) {

    /**
     * How to document such a property-namespace?
     */
    this.name = {
        /**
         * How to document such a property?
         */
        first: forename,

        /**
         * How to document such a property?
         */
        second: surname
    };

}

UPDATE:

Using @namespace and @property does work, but it is displayed under Namespaces instead of Members or Properties, and only as a link that takes me to a separate page, which is awkward, since I'm documenting just a single class. Even worse, such a namespace appears on the list of global namespaces also. Seems like a bad solution. Is there a better one?

Upvotes: 2

Views: 139

Answers (1)

vitaly-t
vitaly-t

Reputation: 25840

This works:

/**
 * @constructor User
 * @param forename
 * @param surname
 */
function User(forename, surname) {

    /**
     * @member {Object} User.name
     *
     * @property {String} forename
     *
     * @property {String} surname
     */
    this.name = {
        forename: forename,
        surname: surname
    };

}

Thanks @mostruash!

Upvotes: 1

Related Questions