I am trying to use jsdoc with .jsx files and seems doesn't work. I can build the .jsx files and then try to generate the documentation but I really don't like that solution.
Are you going to support .jsx?
I don't currently have plans to support JSX. However, it would be possible to do so, since JSDoc uses a JS parser that supports JSX.
Keeping this open as an enhancement request.
I should add that I have some reservations about supporting JSX. The biggest is that JSDoc would be stuck using a JavaScript parser that supports JSX, which would limit our options if we needed to change parsers in the future. (And we've already changed parsers twice, so there's a reasonably high likelihood that this will happen again.)
Would love to see this :+1:
+1
:+1:
I created a plugin (jsdoc-jsx), where I manage to get this to work by transforming my JSX files with esprima before they are processed by JSDoc.
@ctumolosus That's awesome but I would like to see this on JSDoc too.
Great job!
The biggest is that JSDoc would be stuck using a JavaScript parser that supports JSX, which would limit our options if we needed to change parsers in the future.
@hegemonic Totally understand where you're coming from, but the developer interest in JSX is so high now and going forward. Most of the actively-maintained parsers do support JSX for free now, like https://github.com/eslint/espree.
@hegemonic any update in this? Even Babel is supporting JSX so I think like @yaycmyk this feature is on demand right now
+1 @hegemonic, any update?
Anyone know whether jsdoc-jsx works together with grunt-jsdoc?
I tried it but got an error that points to jsdoc-jsxnode_modules\jstransform\src\simple.js:105:28
Thank you
I've added JSX support on GitHub master. JSX support will be included in JSDoc 3.4.0. For now, if you want JSX support, use GitHub master, not the npm version of JSDoc.
It's very likely that the current implementation has some bugs. If JSDoc can't handle your JSX code, please file a new issue, and include a code sample that reproduces the error.
Thanks for adding jsx to master. I used that version and it gave documentation. however for some of the classes it gave the following warning : WARNING: JSDoc does not currently handle ArrowFunctionExpression nodes. So how do I deal with that? arrow functions are an integral part of my code.
Thank you
@ewaldman JSDoc currently ignores arrow functions. This is a temporary limitation. In many cases, it won't affect your documentation at all.
@hegemonic Is there a flag that needs to be flipped to enable JSX support? Running the latest 4.0 beta locally and they're still not being processed :(
My config is
{
"opts": {
"template": "../node_modules/minami"
},
"plugins": []
}
And running it with
find src -type f -name '*.js' -o -name '*.jsx' | xargs jsdoc -d docs/api -c docs/jsdoc.json
I can confirm that the find is definitely picking up the jsx files
@yaycmyk This issue was caused by a silly oversight on my part--by default, JSDoc still wasn't looking for files with the extension .jsx. This is now fixed on GitHub master.
Ahh got it! Thank you very much :)
Most helpful comment
I've added JSX support on GitHub master. JSX support will be included in JSDoc 3.4.0. For now, if you want JSX support, use GitHub master, not the npm version of JSDoc.
It's very likely that the current implementation has some bugs. If JSDoc can't handle your JSX code, please file a new issue, and include a code sample that reproduces the error.