0

I have some modules, where I export Objects (as const) that contain several objects and those objects contain certain properties or functions.

For better readability I decided against direct nested structure ({ foo: {} }) in favour of assigning the objects (someObj.foo = {}).

I try to document them with JsDoc (using better-docs template) but the problem here is, that the nested properties are only generated when defined on the top-level Object:


/**
 * Representation of users in the database.
 *
 * @module
 * @property {object} schema the db schema
 * @property {object} schema.username username schema
 * @property {function} schema.username.type type of the username schema
 */
export const Users = {}


Users.schema = {
  username: {
    type: String,
  },
}

Result:

enter image description here

However, I'd rather want to document the properties in-place for maximum readability and understanding:

/**
 * Representation of users in the database.
 *
 * @module
 * @type {object}
 */
export const Users = {}

/**
 * the db schema
 * @type {object}
 */
Users.schema = {
  /**
   * username schema
   * @type {object}
   */
  username: {
    /**
     * type of the username schema
     * @type {function}
     */
    type: String,
  },
}

Result:

enter image description here

Using @memberOf has also no further effect.

How can I resolve this without the need to document everything in the top-level object?

Jankapunkt
  • 8,128
  • 4
  • 30
  • 59

0 Answers0