Skip to content

Support async functions #2

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

Open
tunnckoCore opened this issue Feb 17, 2018 · 6 comments
Open

Support async functions #2

tunnckoCore opened this issue Feb 17, 2018 · 6 comments

Comments

@tunnckoCore
Copy link

tunnckoCore commented Feb 17, 2018

It seems easy. I may PR soon.

Currently, you can add @name, but it always adds dot before the given name. Not sure if exactly this comes from here.

@tunnckoCore
Copy link
Author

Current workaround is to create another function that just calls the async one and to put the comment on top it.

/**
 * jsdoc comment here
 */
module.exports = function charlike(...args) {
  return charlikeOrig(...args);
};

@tunnckoCore
Copy link
Author

tunnckoCore commented Feb 17, 2018

Actually the dot comes from js-comments here.

@doowb
Copy link
Collaborator

doowb commented Feb 17, 2018

@olstenlarck what's the issue that you're actually having? Are async functions causing an error? Can you provide an example of the function, the code comments, and the output?

@tunnckoCore
Copy link
Author

Yea, sorry.

/**
 * Foo bar baz.
 *
 * @param  {String} `<name>` project name
 * @param  {String} `<desc>` project description
 * @param  {Object} `[options]` use `options.locals` to pass more context to template files,
 *                              use `options.engine` for different template engine to be used
 *                              in template files, or pass `options.render` function
 *                              to use your favorite engine
 * @return {Promise} if successful, resolved promise with absolute path to the project
 * @api public
 */

export default async function charlike(name, desc, options) {
  if (typeof name !== 'string') {
    throw new TypeError('charlike: expect `name` to be string');
  }
  // ...
}

Does not outputs API. So you can set @name but when you set it, it automatically adds . in front of what you set, so in the docs it shows .charlike and that problem comes from js-comments. It is nice default behaviour, but for methods and etc, not when you don't have any other way to set name and when you want to describe default export.

@tunnckoCore
Copy link
Author

tunnckoCore commented Feb 17, 2018

For the sake of simplicity for me, locally i just comment these lines in js-comments.

@doowb
Copy link
Collaborator

doowb commented Feb 17, 2018

@olstenlarck thanks for the additional information. It looks like the regex in some of the parsers just needs to be updated to also capture async functions and categorize them with the proper .type. Pretty much what you said originally, but I didn't understand entirely what the issue was. If you'd like to do a PR, that'd be appreciated.

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

No branches or pull requests

2 participants