esdoc / esdoc

ESDoc - Good Documentation for JavaScript
https://esdoc.org
MIT License
2.74k stars 204 forks source link

TypeError: Cannot read property 'split' of undefined #301

Closed damirka closed 7 years ago

damirka commented 8 years ago

Getting this error when trying to generate docs for multiple files.

Here is a log:

badge.svg
identifiers.html
index.html
class/components/redis/Connection.js~Connection.html
class/components/errors/DebugError.js~DebugError.html
class/components/errors/EmptyDataError.js~EmptyDataError.html
/usr/lib/node_modules/esdoc/out/src/Publisher/Builder/ClassDocBuilder.js:79
            throw _iteratorError;
            ^
TypeError: Cannot read property 'split' of undefined
    at /usr/lib/node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:1287:53
    at IceCap.loop (/usr/lib/node_modules/esdoc/node_modules/ice-cap/out/src/IceCap.js:261:9)
    at ClassDocBuilder._buildProperties (/usr/lib/node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:1285:11)
    at /usr/lib/node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:651:41
    at IceCap.loop (/usr/lib/node_modules/esdoc/node_modules/ice-cap/out/src/IceCap.js:261:9)
    at ClassDocBuilder._buildDetailDocs (/usr/lib/node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:606:11)
    at ClassDocBuilder._buildDetailHTML (/usr/lib/node_modules/esdoc/out/src/Publisher/Builder/DocBuilder.js:568:29)
    at ClassDocBuilder._buildClassDoc (/usr/lib/node_modules/esdoc/out/src/Publisher/Builder/ClassDocBuilder.js:172:44)
    at ClassDocBuilder.exec (/usr/lib/node_modules/esdoc/out/src/Publisher/Builder/ClassDocBuilder.js:64:36)
    at publish (/usr/lib/node_modules/esdoc/out/src/Publisher/publish.js:169:59)

And this is my config:

{
  "access": ["public", "protected", "private"],
  "source": "./app/components",
  "destination": "./out/esdoc",
  "undocumentIdentifier": true,
  "unexportIdentifier": true,
  "autoPrivate": false,
  "lint": false
}
moroine commented 8 years ago

Same issue on my side

damirka commented 8 years ago

To @moroine:

I've found a way to fix this but it's completely incorrect and weird. Just added this condition:

// in /usr/lib/node_modules/esdoc/out/Publisher/Builder/DocBuilder#1288
if (prop.name === undefined) {
    return ice;
}

If you need a quick fix to generate docs - this can work. But I don't recommend to do it in any other case.

UPD: There's an ice.loop('property', properties, function (i, prop, ice) { ... }) block and in some cases (I didn't go further) prop can be an empty object or smth. So the name property is undefined.

It's funny that I've been migrating from JSDoc and after I removed some JSDoc tags (as I see now) it began to work properly even without this fix. :8ball:

make-github-pseudonymous-again commented 8 years ago

Here's an example that throws a similar error

export class Product {

    constructor ( a , b ) {
        this.a = a ;
        this.b = b ;
    }

    zero ( ) {
        return [ this.a.zero( ) , this.b.zero( ) ] ;
    }

    plus ( [ a , b ] , [ A , B ] ) {
        return [ this.a.plus( a , A ) , this.b.plus( b , B ) ] ;
    }

}

Commenting out the plus method or adding

    /**
     * @param first
     * @param second
     */

just before the plus method makes esdoc work again.

damirka commented 8 years ago

Seems to me it's somehow related to destructive assignment and it's parsing. Did you try any other ways?

// like this one
function example({ a: A, b: B }, c = null, [ d = null ]) {
  // check params inside
}
make-github-pseudonymous-again commented 8 years ago

No but I think your guess is correct.

h13i32maru commented 7 years ago

Thanks for this report.

I will fix this bug in next version.

h13i32maru commented 7 years ago

I fixed this bug. https://github.com/esdoc/esdoc/commit/c8ae3f54837446febb37ac675677d4302552380f

And will release in next version.