jsduck
jsduck copied to clipboard
Add support for generator functions
When I try to generate documentation for a file with generators, I get an error:
Invalid JavaScript syntax: Unexpected '*' on line ##
Try it with this:
function* foo(x) {
yield x + 1;
var y = yield null;
return x + y;
}
I think it could be solved easily ignoring asterisks (*) when they are at the right of the function
keyword.
This really can't be solved with a simple patch like that.
It's a larger issue of RKelly parser not supporting ECMAScript 6, generators being just one of the several features added.
I've been working on RKelly lately, so adding ES6 support is not far-fetched. At least support for some of the ES6 features. Can't really make any promises though.
Ok, I understand the complete fix is to add ES6 support to RKelly, I just wanted to share how I solved it easily. If somebody needs generator support in jsduck can use my patch.