documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Object declarations omit default values

Open webOS101 opened this issue 6 years ago • 2 comments

If you're reporting a bug, please include input code, output documentation, a description of what you expected to happen, and what happened instead. Given the following input:

/**
 * @type {Object}
 * @property {Boolean} [bool=true]
 */

The property declaration in the output properties member does not include the default value. The default value does render into the tags section.

The same happens for @typedef, though I suppose one could argue that typedefs shouldn't have default values anyhow. I suppose maybe it's being treated as a typedef. In any case, if this is not the right way to document an object, tips would be appreciated.

Output:

...
    "tags": [
      {
        "title": "type",
        "description": null,
        "lineNumber": 1,
        "type": {
          "type": "NameExpression",
          "name": "Object"
        }
      },
      {
        "title": "property",
        "description": null,
        "lineNumber": 2,
        "type": {
          "type": "OptionalType",
          "expression": {
            "type": "NameExpression",
            "name": "Boolean"
          }
        },
        "name": "bool",
        "default": "true"
      }
    ],
 ...
    "properties": [
      {
        "title": "property",
        "name": "bool",
        "lineNumber": 2,
        "type": {
          "type": "OptionalType",
          "expression": {
            "type": "NameExpression",
            "name": "Boolean"
          }
        }
      }
    ],
...
  • What version of documentation.js are you using?: 8.1.2
  • How are you running documentation.js (on the CLI, Node.js API, Grunt, other?): cli, node

webOS101 avatar Mar 29 '19 15:03 webOS101

This looks to me like intended behavior - the JSDoc spec doesn’t mention anything about properties having default values.

tmcw avatar Mar 29 '19 15:03 tmcw

Looks like a doc problem on the jsdoc site. As can be seen from bugs related to default values: https://github.com/jsdoc3/jsdoc/issues/791. I opened a doc issue here: https://github.com/jsdoc3/jsdoc/issues/1629. In the case I'm wrong, we'll find out there.

webOS101 avatar Mar 29 '19 17:03 webOS101