gozilla10 / jsdoc-toolkit

Automatically exported from code.google.com/p/jsdoc-toolkit
0 stars 0 forks source link

Fails to parse files containing lambda expressions #330

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Write a function that uses a lambda expression
2. Run jsdoc on the file

What is the expected output? What do you see instead?
I expect all functions in the file to be written to documentation, but all 
functions after the one using a lambda expression are ignored. jsdoc also emits 
a warning:

>> WARNING: Mismatched } character. Can't parse code in file test.js.

What version of the product are you using? On what operating system?
jsdoc-toolkit 2.4.0 on Debian wheezy

Please provide any additional information below.
Lambda expressions are a JavaScript 1.8 feature that allow implicit return 
values of anonymous functions. So something like:

baz.sort(function(a, b) { return a - b; });

could be written as:

baz.sort(function(a, b) a - b);

I'm guessing it's the lack of braces around the function that's confusing 
jsdoc. However, it is valid JavaScript syntax.

I've attached a file that exhibits the problem (bar() is written to 
documentation, but qux(), which comes after it, isn't). Commenting out the line 
with the lambda (line 6) causes both functions to be documented correctly.

Original issue reported on code.google.com by bma...@gmail.com on 8 Dec 2011 at 1:29

GoogleCodeExporter commented 8 years ago
Whoops, messed up on the attachment the first time. Here's the correct one.

Original comment by bma...@gmail.com on 8 Dec 2011 at 2:26

Attachments:

GoogleCodeExporter commented 8 years ago
Unfortunately, adding the ability to parse lambda expressions to JSDoc 2 would 
require a total rewrite of the application.

Fortunately, I already did that.

It's still in beta release but JSDoc 3 will correctly document the sample file 
you attached.

Original comment by micmath on 8 Dec 2011 at 11:05