Closed rgsilva closed 6 years ago
Hi Ricardo, great job digging into this!
I'm perfectly fine with implementing graceful fallback for now. Since I'm not very familiar with the plugin code I can't say it is the proper solution, but I'd rather have it fixed now and find the proper solution later. Feel free to send a PR, and perhaps add a todo or issue to investigate it further when we have the chance!
Thanks! Matt
I'll close this as the fixes are now merged. Thanks a lot!
Hi!
So, as discussed in https://github.com/esdoc2/esdoc2/issues/2, I managed to get esdoc2 working by cloning and building it manually (which is actually better for our workflow here). However, I ran into some issues generating documentation for some test folders.
First thing I did was to modify esdoc2 to show me where unhandled promise rejections crashed, following the instrunctions from StackOverflow: https://stackoverflow.com/questions/43834559/how-to-find-which-promises-is-unhandled-in-nodejs-unhandledpromiserejectionwarni.
I've create a folder called
src
and created thetestfile.js
inside of it:The esdoc2 configuration file is this:
Trying to generate the documentation for that small file resulted in this warning:
By adding the missing (empty)
README.md
, I got the following:There are 2 issues here. The first one is a promise rejection because of an exception, and the second one is a
find
call which is crashing esdoc2. Taking care of the second one first, I saw thatDocBuilder
gets its tags through the constructor. Such instance is created at the plugin itself, and by checking the source, it seems that the_exec
call (https://github.com/esdoc2/esdoc2-plugins/blob/master/packages/esdoc2-publish-html-plugin/src/Plugin.js#L27) is calling withthis._docs
as undefined. By adding aconsole.log
to theonHandleDocs
method of such class, I got pretty much nothing: a call to it was never made. That seems to be the reason why it won't work. A hack was to change the call as this:That fixed the second issue and we at least get some documentation output at the end. However, the first issue (params of undefined) is still present. This is happing because at https://github.com/esdoc2/esdoc2-plugins/blob/master/packages/esdoc2-type-inference-plugin/src/Plugin.js#L120,
node
is actually undefined. Taking a look back at who is calling it, it seems it happens because the following call is returning undefined in some cases:If I add a condition to continue the loop in case the node is undefined (
if (!node) continue;
) to all parts of the code that callgetNode
, the documentation is finally generated. Plus, after doing that,onHandleDocs
is finally called with data:So! Can you tell me if I'm missing something somewhere, or if this is a proper solution (in such case I'll do a PR for you to review)? All I did was a few hacks to get it to carry on without errors, but I don't know the effects of it to the process itself. :)
Thanks! Cheers, Ricardo
PS: fun fact, esdoc2 takes over 10 minutes to run at our current project. I might have to disable some stuff we don't need/use right now :-)