简体   繁体   中英

Are tabs allowed in a JSDoc comment block?

Is it allowed to use tabs in a JSDoc comment block?

    /**
     * Some description
     *
     * @function
     * @name            someName
     * @summary         And a summary
     */

Instead of...

    /**
     * Some description
     *
     * @function
     * @name someName
     * @summary And a summary
     */

It seems JSDoc doesn't have a specification which states whether tabs work or not. But looking at The JSDoc website , it seems all of their examples don't use tabs.

BUT , I tried creating 3 functions - 1 with tabs in the doc, 1 with long tab spacing in the doc and 1 without tabs and use the JSDoc doc generator on them and it seems to work just fine.

The test functions I used:

/**
 * This function receives 3 variables and returns their sum
 * @param   {int}   myvar   - A number
 * @param   {int}   myvara  - A number
 * @param   {int}   myvarb  - A number
 * @return  {int}             The sum of all numbers
 */
function testwithtabs(myvar, myvara, myvarb) {
  return myvar+myvara+myvarb;
}

/**
 * This function receives 3 variables and returns their sum
 * @param   {int}           myvar   - A number
 * @param   {int}           myvara  - A number
 * @param   {int}           myvarb  - A number
 * @return  {int}                     The sum of all numbers
 */
function testwithlargetabs(myvar, myvara, myvarb) {
  return myvar+myvara+myvarb;
}

/**
 * This function receives 3 variables and returns their sum
 * @param  {int} myvar - A number
 * @param  {int} myvara - A number
 * @param  {int} myvarb - A number
 * @return {int}        The sum of all numbers
 */
function testnotabs(myvar, myvara, myvarb) {
  return myvar+myvara+myvarb;
}

So going by this, even though tabs aren't specified in the examples, they will work just fine and you are free to use whatever you are comfortable with

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM