webdoc-labs / webdoc

Documentation generator for the web
https://www.webdoclabs.com
Other
80 stars 9 forks source link

@webdoc/parser `1.6.0` crashes when mangling a method with no parameter #182

Closed Julien-Marcou closed 2 years ago

Julien-Marcou commented 2 years ago

Related to https://github.com/pixijs/pixijs/pull/8480

When @webdoc/parser parses a method that has no parameters, it crashes with the following error:

(node:4199) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'map' of undefined
    at mangled (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/model/lib/doc.js:296:50)
    at discoverMembers (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/mod-discover-members.js:53:45)
    at ensureDiscovered (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/mod-discover-members.js:21:3)
    at discoverMembers (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/mod-discover-members.js:81:5)
    at discover (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/mod-discover-members.js:116:3)
    at Object.discover [as mod] (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/mod-discover-members.js:120:7)
    at mod (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/transformer/document-tree-modifiers.js:66:22)
    at parse (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/parser/lib/parse.js:82:38)
    at async main (/home/runner/work/pixijs/pixijs/node_modules/@webdoc/cli/lib/index.js:136:5)

The mangled() function doesn't check if params is defined, it should probably return something like ${doc.type}:${doc.name} or ${doc.type}:${doc.name}:undefined when that is the case:

https://github.com/webdoc-labs/webdoc/blob/b7cf3dd0dff474936255b994dabd1598727677ac/packages/webdoc-model/src/doc.js#L356-L363

ShukantPal commented 2 years ago

It fails here: https://github.com/pixijs/pixijs/blob/9b724f289118ebbf9b4500fa3faab1e7aaaabd02/packages/display/src/DisplayObject.ts#L324