Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript destructuring #180

Open
DdZ-Fred opened this issue May 22, 2016 · 6 comments
Open

JavaScript destructuring #180

DdZ-Fred opened this issue May 22, 2016 · 6 comments

Comments

@DdZ-Fred
Copy link

Hi everyone!

I thought recognizing destructuring in function params could be a good enhancement!
This is the actual result when it is used:

/**
 * [handleRecaptchaErrors description]
 * @param  {[type]} res        [description]
 * @param  {[type]} {          status        [description]
 * @param  {[type]} statusText [description]
 * @param  {[type]} config     }             [description]
 * @return {[type]}            [description]
 */
export function handleRecaptchaErrors(res, { status, statusText, config }) {
  // Code here
}

Getting something similar to this could be convenient:

/**
 * Handles the errors that can occur when requesting the reCatpcha API
 * @param  {Object} res                      [HTTP response of the /contactMe resource]
 * @param  {Object} recaptchaRequestResponse [Axios response received requesting the reCaptcha API]
 *         @property  {Number}  status       [Status code]
 *         @property  {String}  statusText   [Status message]
 *         @property  {Object}  config       [Original axios request config]
 */
 export function handleRecaptchaErrors(res, { status, statusText, config }) {
  // Code here
}

That being said, I'm really not comfortable with RegExp (...I should start learning) so not sure I can implement this myself

@dirchev
Copy link

dirchev commented Aug 1, 2016

Hey there!

Same goes when you use ES6 Spread Operator as function parameter:

/**
 * [example description]
 * @param  {[type]} prop     [description]
 * @param  {[type]} ...props [description]
 * @return {[type]}          [description]
 */
function example (prop, ...props) {
  // Code here
}

I do not have a good idea how to handle Spread Operator parameters. Maybe just defining their type to be Array 💭

@MoritzKn
Copy link
Collaborator

MoritzKn commented Sep 9, 2016

@dirchev could you please open a new issue for adding support for the spread operator.

@MoritzKn
Copy link
Collaborator

MoritzKn commented Sep 9, 2016

This should be addressed with some prio cause it's causing exceptions (See #219 and #197).

@sompylasar
Copy link

I do not have a good idea how to handle Spread Operator parameters. Maybe just defining their type to be Array

The coder may want to make it Array<{type}> so maybe that should be the placeholder.

@noahehall
Copy link

+1 on this issue

@SKalt
Copy link

SKalt commented Oct 16, 2018

With docblockr 0.13.7 and atom 1.31.2, the package correctly handles

function foo(x, {a, b}) { /* etc */ }
// results in 
/**
 * [foo description]
 * @param  {[type]} x [description]
 * @param  {[type]} a [description]
 * @param  {[type]} b [description]
 * @return {[type]}   [description]
 */

but

function bar(x, {a, b} = {a: 1, b: "2"}) {/* etc */}
// results in
/**
 * [foo description]
 * @param  {[type]} x [description]
 * @param  {[type]} a [description]
 * @param  {[type]} b [description]
 * @param  {[type]} b [description]
 * @return {[type]}   [description]
 */

No errors or docblockr-related warnings are written to the console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants