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

Support for arrow => functions #34

Open
semmel opened this issue Sep 9, 2017 · 2 comments
Open

Support for arrow => functions #34

semmel opened this issue Sep 9, 2017 · 2 comments

Comments

@semmel
Copy link

semmel commented Sep 9, 2017

/**
 * @example
 *    divide(10, 10) // => 1
 */
const divide = (x, y) => x / y;

is not recognised by jsdoctest ("0 passing") because dox.js detects a declaration:

...
ctx: 
     { type: 'declaration',
       name: 'divide',
       value: '(x, y) =>'
...

This could be fixed easy by supplying a regular expression for ES6 arrow functions which would then change the context to function.
Right in the same way (with some regular expressions ) support for async/await can be added. As discussed here: #31.

Where should this happen? Should I prepare a pull request into dox.js or into jsdoctest by using the dox api for context matching?

I'd prefer patching getJsdoctests() here.

@yamadapc
Copy link
Owner

yamadapc commented Sep 9, 2017

Hm... Is the value incorrectly trimmed like that? I'd rather not use RegExp to parse JavaScript and have that be in dox or it's parsing lib, for sure.

If you're able to do it in a reliable way with RegExp I would gladly accept it though. I'm just not very confident about that solution.

@semmel
Copy link
Author

semmel commented Sep 10, 2017

Yeah you're probably right that all those RegExpes do not belong here. I am just not confident that a pull request would be accepted in tj/dox because the activity there is low.

However I am half-way through in upgrading my fork of dox with async and arrow functions. It is not that difficult with the work @cjy37 has done but writing the missing tests takes time...

On the topic of async functions I'd really like to see the promise syntax ~> ~!> @jmatsushita has implemented in his fork of jsdoctest to be supported. But I don't know if he's done more than this syntactic improvement that cannot be merged back to jsdoctest.

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