Wikunia / brackets-FuncDocr

FuncDocr generates JS/PHPDoc annotations for your functions
101 stars 14 forks source link

Default value setting has to be single line #81

Closed kosinaz closed 8 years ago

kosinaz commented 8 years ago

Based on acknowledged style guides it is good practice to always follow a conditional or iteration statement with a block statement, even when said block would contain only a single statement. But doing so in the default value setting prevents the value to appear in the comments.

Working version:

/**
 * [[Description]]
 * @param {[[Type]]} [a=1] [[Description]]
 */
var func = function (a) {
  if (typeof a === 'undefined') a = 1;
};

Current result:

/**
 * [[Description]]
 * @param {[[Type]]} a [[Description]]
 */
var func = function (a) {
  if (typeof a === 'undefined') {
    a = 1;
  }
};

Expected result:

/**
 * [[Description]]
 * @param {[[Type]]} [a=1] [[Description]]
 */
var func = function (a) {
  if (typeof a === 'undefined') {
    a = 1;
  }
};
kosinaz commented 8 years ago

Almost perfect, but sadly there is still an issue with multiple default values.

Working version:

/**
 * @param {[[Type]]} [a=1] [[Description]]
 * @param {[[Type]]} [b=2] [[Description]]
 * @param {[[Type]]} [c=3] [[Description]]
 */
var func = function (a, b, c) {
  'use strict';
  if (typeof a === 'undefined') a = 1;
  if (typeof b === 'undefined') b = 2;
  if (typeof c === 'undefined') {
    c = 3;
  }
};

Current result:

/**
 * 
 */
var func = function (a, b, c) {
  'use strict';
  if (typeof a === 'undefined') a = 1;
  if (typeof b === 'undefined') {
    b = 2;
  }
  if (typeof c === 'undefined') {
    c = 3;
  }
};

Expected result:

/**
 * @param {[[Type]]} [a=1] [[Description]]
 * @param {[[Type]]} [b=2] [[Description]]
 * @param {[[Type]]} [c=3] [[Description]]
 */
var func = function (a, b, c) {
  'use strict';
  if (typeof a === 'undefined') a = 1;
  if (typeof b === 'undefined') {
    b = 2;
  }
  if (typeof c === 'undefined') {
    c = 3;
  }
};