2

I have a class that takes an options object with a lot of configurations inside.

const DEFAULTS = {
  a: 1,
  b: {
    c: 2,
    d: 3
  }
}

export default class Popper {
  constructor(options) {
    ...

I'm documenting the options properties manually but I'd like to define the default value using the one of the DEFAULTS variable.
Something like the following doesn't work, how can I do?

@param {Object} [options.b=DEFAULTS.b] - The defaults b options
2
  • Doesn't work how? It crashes? It does not look the way you want? (If the latter, then what does it look like, and what would you like it to look like instead?) Commented Aug 23, 2016 at 16:52
  • It just doesn't take the value from the DEFAULTS.b property, I would like it to take the value from it. Nothing more to add honestly Commented Aug 23, 2016 at 19:56

1 Answer 1

2

I don't think jsdoc is prepared to substitute values, template-like. So an option here would be to document the constant, and make a reference to it, like so:

/**
* Default values for options
* @param {number} [ a = 1 ] - this is a
* And so on...
*/
const DEFAULTS = {
  a: 1,
  b: {
    c: 2,
    d: 3
  }
}



export default class Popper {
  /**
  * Popper
  * @param {Object} [options = DEFAULT] See [[DEFAULT]]
  */
  constructor(options) {
    ...

That way the reader can properly be directed to these default values.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.