1

I just started to use JSDoc to (try to) start writing documentation. I have 4 global variables at the start of my js file:

var controller = -1,
action = 'none',
maxValue = 0,
URLs = []; 

how can I document all of those inside an initial comment block? So far the only way I made it work was using a block code per variable in this way:

/**
* Some description.
* @type {number}
*/
var controller = -1,
/**
* Some description.
* @type {string}
*/
action = 'none',
/**
* Some description.
* @type {number}
*/
maxValue = 0,
/**
* Some description.
* @type {array}
*/
URLs = []; 

Is this the only/correct way to do this?

distante
  • 6,438
  • 6
  • 48
  • 90
  • How about **not** using globals and making these properties of a class/namespace and then you will be able to follow the JSDoc style for that and not have the problem (and get rid of the nasty, nasty, globals at the same time)> – jwpfox Aug 26 '16 at 13:13
  • 1
    What about in an encapsulated function? `(function(){...}()` – distante Aug 26 '16 at 20:27
  • Like this maybe? [http://stackoverflow.com/questions/38708777/what-is-the-correct-jsdoc-syntax-for-a-local-variable](http://stackoverflow.com/questions/38708777/what-is-the-correct-jsdoc-syntax-for-a-local-variable) – jwpfox Aug 27 '16 at 00:59
  • So exactly as I posted but inside the function. – distante Aug 27 '16 at 05:30

0 Answers0