JSDoc Template Object

Is there a way to freely indicate which objects should be inside the object you are documenting?

I want to document an object from the following:

var obj = {
  unknownName1: {
    name: "KnownValue"
  },
  unknownName2: {
    name: "KnownValue",
    offset: {
      x: 0,
      y: 0
    }
  },
  unknownName3: {
    name: "KnownValue",
    offset: {
      x: 0,
      y: 0
    },
    visible: true
  },
  unknownName4: {
    name: "KnownValue"
  }
};

Sub-objects must have the following properties:

/**
 * Example Object
 * @typedef myObject
 * @type {Object}
 * @property {String} name - Name of the templated object
 * @property {Number} [offset.x] - Offset X
 * @property {Number} [offset.y] - Offset Y
 * @property {Boolean} [visible] - Is Visible
 * @memberof com.namespace.MyClass 
 */

If I wanted to write this particular one obj, I would do the following, but the object will be dynamically generated with an unknown number of objects of unknown name with typecom.namespace.MyClass

/**
 * Object of Special Objects
 * @typedef mySpecialObjectOfObjects
 * @type {Object}
 * @property {com.namespace.MyClass.myObject} unknownName1
 * @property {com.namespace.MyClass.myObject} unknownName2
 * @property {com.namespace.MyClass.myObject} unknownName3
 * @property {com.namespace.MyClass.myObject} unknownName4
 * @memberof com.namespace.MyClass
 */

PS I'm just looking for a wildcard @propertythat can be used so that my editor can help me remember all the options available for each sub-object inside the object.

+4
source share

Source: https://habr.com/ru/post/1589086/


All Articles