What is the correct JSDoc syntax for a local variable?

For such a function ...

function example() {
  var X = 100;

  ...

  var Y = 'abc';

  ...

  return Z;
}

I need to explain the purpose of some local variables. Add a description like this ...

function example() {
  /**
   * @description - Need to explain the purpose of X here.
   */
  var X = 100;

  ...

  /**
   * @description - Need to explain the purpose of Y here.
   */
  var Y = 'abc';

  ...

  return Z;
}

... doesn't seem to be matched JS Doc v3.4.0.

What is the correct syntax?

PS Some of my use cases require multi-line comments.

+4
source share
2 answers

JS Docs seems to ignore comments in the block (e.g. class, function, etc.). I tried...

@description
@inner
@instance
@member
@memberof
@name
@summary

... other. I could not get any of them to create documentation. For all JS Doc examples, they use regular JS comments for this kind of thing.

, JS Doc.

+1

- .

function example() {
  /**
   * Need to explain the purpose of X here.
   * @type {number}
   */
  var X = 100;

  ...

  /**
   * Need to explain the purpose of Y here.
   * @type {string}
   */
  var Y = 'abc';

  ...

  return Z;
}
+4

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


All Articles