senchalabs / jsduck

Simple JavaScript Duckumentation generator.
http://docs.sencha.com/
GNU General Public License v3.0
1.5k stars 238 forks source link

Stack level too deep error using inheritdoc on method of class missing comment #659

Open jbohmann opened 7 years ago

jbohmann commented 7 years ago

jsduck 5.3.4

I'm hoping this situation can be detected or a better error can be reported. It was hard to track down the problem (missing class docs on ClassB):

//test.js

/**
 * Class A
 */ 
Ext.define('xyz.ClassA', {

    /**
     * Docs for Class A method X.
     */
    methodX: function() {}
});

Ext.define('xyz.ClassB', {

    /**
     * Docs for Class B method X.
     * @inheritdoc xyz.ClassA#methodX
     */
    methodX: function() {}
});

running jsduck like so:

jsduck --verbose ./3rdparty/extjs/4.2.2/ext-all.js test.js --output ./output

fails with this message:

/var/lib/gems/2.3.0/gems/jsduck-5.3.4/lib/jsduck/class.rb:160:in `each': stack level too deep (SystemStackError)
    from /var/lib/gems/2.3.0/gems/jsduck-5.3.4/lib/jsduck/class.rb:160:in `find_all'
    from /var/lib/gems/2.3.0/gems/jsduck-5.3.4/lib/jsduck/class.rb:160:in `find_members'
    from /var/lib/gems/2.3.0/gems/jsduck-5.3.4/lib/jsduck/process/inherit_members.rb:229:in `lookup_member'
    from /var/lib/gems/2.3.0/gems/jsduck-5.3.4/lib/jsduck/process/inherit_members.rb:157:in `find_parent'
    from /var/lib/gems/2.3.0/gems/jsduck-5.3.4/lib/jsduck/process/inherit_members.rb:50:in `resolve_member'
    from /var/lib/gems/2.3.0/gems/jsduck-5.3.4/lib/jsduck/process/inherit_members.rb:75:in `resolve_parent'
    from /var/lib/gems/2.3.0/gems/jsduck-5.3.4/lib/jsduck/process/inherit_members.rb:52:in `resolve_member'
    from /var/lib/gems/2.3.0/gems/jsduck-5.3.4/lib/jsduck/process/inherit_members.rb:75:in `resolve_parent'
     ... 9028 levels...
    from /var/lib/gems/2.3.0/gems/jsduck-5.3.4/lib/jsduck/app.rb:21:in `run'
    from /var/lib/gems/2.3.0/gems/jsduck-5.3.4/bin/jsduck:25:in `<top (required)>'
    from /usr/local/bin/jsduck:23:in `load'
    from /usr/local/bin/jsduck:23:in `<main>'

Adding a comment block to ClassB (even an empty one) fixes the issue.

Of course, we want to document ClassB and should always do so. The difficulty was finding the cause of this error, mainly due to how many files our project has and that jsduck was being run on a concatenated intermediate (large) file.

nene commented 7 years ago

Thanks for reporting. Looks like a genuine bug.

Maybe I get to fixing this... but it's been a while since I really did any maintenance on JSDuck. Just saying, so you don't get your hopes up.

But thanks.