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

Error when just parsing comments #2

Closed
CMatias opened this issue Apr 13, 2016 · 3 comments
Closed

Error when just parsing comments #2

CMatias opened this issue Apr 13, 2016 · 3 comments

Comments

@CMatias
Copy link

CMatias commented Apr 13, 2016

I'm using esprima and I've the need of parsing comments. Esprima conveniently provides an array with comments which I'll use along with the jsdoc-api to extract useful info.

Thing is, when using explainSync (and probably other methods but I've only tested explainSync), if only the comment is provided the results are unexpected.

console.log(jsdoc.explainSync({ source: '/** example doclet */ \n var example = true' })); 
//Outputs as expected.

console.log(jsdoc.explainSync({ source: '/** example doclet */' }));  
/* Outputs:
[ { kind: 'package',
    longname: 'package:undefined',
    files: [ '/tmp/ebm4dtq81kqhbyb9aa2p72j45l3gcik9.js' ] } ]
*/

Is this expected behaviour?

@75lb
Copy link
Member

75lb commented Apr 13, 2016

jsdoc-api uses jsdoc3 under the hood, not doctrine.. the general rule is "if it works in jsdoc it will work in jsdoc-api".. i don't think your example above is valid jsdoc3 input.. i will check later when i get a moment..

@CMatias
Copy link
Author

CMatias commented Apr 13, 2016

I get that since jsdoc was made to parse entire files and not only comment strings. Since this is named "api" I thought that would be a core function. The code works if I append a piece of valid code on the end of the comment like "var t = true;", however, support for only comment strings is a nice feature.

@75lb
Copy link
Member

75lb commented Apr 13, 2016

this project is an API wrapper for jsdoc3, which does not export any library code at all (it is command-line only).. it exists to workaround the design short-comings of jsdoc3 (an old codebase).. maybe that is not clear enough in the docs..

jsdoc3 works with whole js source files.. doctrine works with comment blocks only, but supports less tags.

@75lb 75lb closed this as completed Apr 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants