Keep getting error
SilentImp opened this issue · comments
Hi, I have tried add plugin to the project project with following config:
{
"source": "./src/app/components",
"destination": "./esdoc",
"includes": ["\\.(js|jsx)$"],
"excludes": ["\\__tests__","\\__mocks__"],
"access": ["public", "protected", "private"],
"autoPrivate": true,
"unexportIdentifier": false,
"undocumentIdentifier": true,
"builtinExternal": true,
"index": "./README.md",
"package": "./package.json",
"coverage": true,
"includeSource": true,
"title": "Contributors",
"plugins": [
{"name": "esdoc-jsx-plugin", "option": {"enable": true}}
],
"lint": true,
"experimentalProposal": {
"classProperties": true,
"objectRestSpread": true,
"decorators": true,
"doExpressions": true,
"functionBind": true,
"asyncGenerators": true,
"exportExtensions": true,
"dynamicImport": true
}
}
but when I try to generate documentation I have got:
$ npm run esdoc
> plasma-contributors@0.0.1 esdoc /project
> esdoc
parse: /project/src/app/components/App/index.jsx
/project/node_modules/esdoc/out/src/Util/InvalidCodeLogger.js:73
const start = Math.max(error.loc.line - 3, 1);
^
TypeError: Cannot read property 'line' of undefined
at InvalidCodeLogger.showFile (/project/node_modules/esdoc/out/src/Util/InvalidCodeLogger.js:73:37)
at Function._traverse (/project/node_modules/esdoc/out/src/ESDoc.js:291:35)
at _walk.filePath (/project/node_modules/esdoc/out/src/ESDoc.js:119:25)
at Function._walk (/project/node_modules/esdoc/out/src/ESDoc.js:266:9)
at Function._walk (/project/node_modules/esdoc/out/src/ESDoc.js:268:14)
at Function.generate (/project/node_modules/esdoc/out/src/ESDoc.js:103:10)
at ESDocCLI.exec (/project/node_modules/esdoc/out/src/ESDocCLI.js:75:23)
at Object.<anonymous> (/project/node_modules/esdoc/out/src/ESDocCLI.js:186:7)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
Any ideas what may have go wrong?
Is related to Plugin.js file in the ecmascript-proposal plugin... a workaround is to change line 4 with
const plugins = ev.data.option.plugins;
Currently there is a ev.data.parserOption that is never passed...
I've found it could be related to gulp-esdoc in my configuration...
Hi, I've got the same error since I updated from 0.5.x to 1.x. I would be glad to help identifying the issue.
I just found out that the issue came from the general esdoc installation, that was not updated to 1.x, when updated the error disappeared.
I have similar issue with objectRestSpread option of esdoc-ecmascript-proposal-plugin
Another options are good
{
"source": "./src",
"destination": "./docs",
"plugins": [
{"name": "esdoc-ecmascript-proposal-plugin", "option": {
"objectRestSpread": true
}}
]
}
Error stacktrace
/Users/mxtnr/rocket/sun/node_modules/esdoc-type-inference-plugin/src/Plugin.js:157
typeMap[prop.key.name] = '*';
^
TypeError: Cannot read property 'name' of undefined
at Plugin._inferenceParam (/Users/mxtnr/rocket/sun/node_modules/esdoc-type-inference-plugin/src/Plugin.js:157:31)
at Plugin._inferenceFunction (/Users/mxtnr/rocket/sun/node_modules/esdoc-type-inference-plugin/src/Plugin.js:40:42)
at Plugin._exec (/Users/mxtnr/rocket/sun/node_modules/esdoc-type-inference-plugin/src/Plugin.js:18:10)
at Plugin.onHandleDocs (/Users/mxtnr/rocket/sun/node_modules/esdoc-type-inference-plugin/src/Plugin.js:11:10)
at Plugin._execHandler (/Users/mxtnr/rocket/sun/node_modules/esdoc/out/src/Plugin/Plugin.js:55:26)
at Plugin.onHandleDocs (/Users/mxtnr/rocket/sun/node_modules/esdoc/out/src/Plugin/Plugin.js:135:10)
at Function.generate (/Users/mxtnr/rocket/sun/node_modules/esdoc/out/src/ESDoc.js:133:32)
at ESDocCLI.exec (/Users/mxtnr/rocket/sun/node_modules/esdoc/out/src/ESDocCLI.js:71:23)
at Object.<anonymous> (/Users/mxtnr/rocket/sun/node_modules/esdoc/out/src/ESDocCLI.js:182:7)
at Module._compile (module.js:569:30)
So what's the status here? Do we know whether it's an issue with esdoc-type-inference-plugin
or with esdoc-ecmascript-proposal-plugin
?
I put a console.log just before https://github.com/esdoc/esdoc-plugins/blob/master/esdoc-type-inference-plugin/src/Plugin.js#L157, and from what I see.. Usually, prop
indeed is an object with a key property, for example:
>> { prop:
{ type: 'ObjectProperty',
start: 116,
end: 127,
loc: { start: [Object], end: [Object] },
method: false,
shorthand: true,
computed: false,
key:
{ type: 'Identifier',
start: 116,
end: 122,
loc: [Object],
name: 'repeat',
[Symbol(already)]: true },
value:
{ type: 'AssignmentPattern',
start: 116,
end: 127,
loc: [Object],
left: [Object],
right: [Object],
[Symbol(already)]: true },
extra: { shorthand: true },
[Symbol(already)]: true }
For me, when it fails, this is the prop object:
>> { prop:
{ type: 'RestProperty',
start: 129,
end: 139,
loc: { start: [Object], end: [Object] },
argument:
{ type: 'Identifier',
start: 132,
end: 139,
loc: [Object],
name: 'options',
[Symbol(already)]: true },
[Symbol(already)]: true },
key: undefined,
name: undefined }
@a-x- have you found a workaround? Or does it mean we must avoid spread properties?
(I have another project with a much older esdoc setup, esdoc@0.5.2
and esdoc-es7-plugin@0.0.3
, and everything works fine there. I'd rather use that old setup than not use object spread)
no, I didn't
Well I disabled the esdoc-type-inference-plugin
for now, and it "helps" - not sure what it would normally do tho, its functionality must be missing now.
{
"name": "esdoc-type-inference-plugin",
"option": {
"enable": false
}
},
@loopmode or anyone else that comes across this issue, you can work around it by creating a jsdoc definition for the parameter yourself. This way it doesn't have to use the inference plugin to figure it out.
/**
* Foobar does stuff
*
* @param {Object} [options={}]
* @param {Boolean} [options.foo='bar']
* @param {...*} [options.rest] <- Throws error without this.
*/
export function foobar({ foo = 'bar', ...rest } = {}) {
console.log(foo, ...rest);
}
Having said that, does anyone know the correct way to document rest parameters in an object?
Is it @param {...*} [options.rest]
or @param {*} [...options.rest]
Both seem to work okay but the generated docs end up slightly different.