naver / jsdoc-to-mdx

jsdoc to mdx API document generator
https://naver.github.io/jsdoc-to-mdx/
MIT License
20 stars 5 forks source link

ERROR: Unable to parse dummy-project #8

Closed selankon closed 1 year ago

selankon commented 1 year ago

I got the following error trying to parse the dummy-project copied from the installed node-module.

ERROR: Unable to parse /home/user/project/dummy-project/class/DummyClass.ts: Unexpected token, expected "{" (19:37)
ERROR: Unable to parse /home/user/project/dummy-project/class/ParentClass.ts: Unexpected token (16:9)
ERROR: Unable to parse /home/user/project/dummy-project/const/consts.ts: Missing semicolon. (11:1)
ERROR: Unable to parse /home/user/project/dummy-project/global/SomeGlobalFunction.ts: Unexpected token, expected "," (10:29)
ERROR: Unable to parse /home/user/project/dummy-project/interface/DummyInterface.ts: Unexpected reserved word 'interface'. (11:0)
ERROR: Unable to parse /home/user/project/dummy-project/interface/OtherInterface.ts: Unexpected reserved word 'interface'. (11:0)
ERROR: Unable to parse /home/user/project/dummy-project/interface/ParentInterface.ts: Unexpected reserved word 'interface'. (7:0)
ERROR: Unable to parse /home/user/project/dummy-project/typedef/DummyTypedef.ts: Missing semicolon. (6:4)
/home/user/project/node_modules/child-process-promise/lib/index.js:132
            var err = new ChildProcessError(message, code, cp);

ChildProcessError: `npx @daybrush/jsdoc -X -r -c ./jsdoc.json -d /tmp/tmp-80634-B6rkSgdVc3Ye` failed with code 1
    at ChildProcess.<anonymous> (/home/user/project/node_modules/child-process-promise/lib/index.js:132:23)

How to reproduce:

  1. Using Node.js v18.12.1
  2. Docusaurus start as usual
  3. Install yarn add -D jsdoc-to-mdx (install "jsdoc-to-mdx": "^1.1.2", version)
  4. cp -r node_modules/jsdoc-to-mdx/dummy-project .
  5. Create configuration files:
{
  "locales": ["ko"],
  "outDir": "./docs/docs/api",
  "localesDir": "./docs/i18n/{locale}/docusaurus-plugin-content-docs/current/api",
  "sidebar": "./docs",
  "prefix": "api/",
  "jsdoc": "./jsdoc.json"
}
{
  "tags": {
    "allowUnknownTags" : true,
    "dictionaries": ["jsdoc", "closure"]
  },
  "source": {
    "include": ["dummy-project"],
    "includePattern": ".+\\.(j|t)s(doc|x)?$",
    "excludePattern": "(^|\\/|\\\\)_"
  }
}
{
  "extends": "@tsconfig/docusaurus/tsconfig.json",
  "compilerOptions": {
    "jsx": "react",
    "baseUrl": ".",
    "paths": {
      "@assets/*": ["src/assets/*"],
      "@components/*": ["src/components/*"],
      "@hooks/*": ["src/hooks/*"],
    },
    "module": "ES2015",
    "target": "es6",
    "outDir": "./dist/",
    "moduleResolution": "node",
    "lib": ["es2015"],
    "sourceMap": true,
    "strictNullChecks": true,
    "downlevelIteration": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "resolveJsonModule": true,
    "esModuleInterop": true
  }
}
  1. Just run npx jsdoc-to-mdx -c jsdoc-to-mdx.config.json and got the error above
Full stacktrace ``` ERROR: Unable to parse /home/user/project//dummy-project/class/DummyClass.ts: Unexpected token, expected "{" (19:37) ERROR: Unable to parse /home/user/project//dummy-project/class/ParentClass.ts: Unexpected token (16:9) ERROR: Unable to parse /home/user/project//dummy-project/const/consts.ts: Missing semicolon. (11:1) ERROR: Unable to parse /home/user/project//dummy-project/global/SomeGlobalFunction.ts: Unexpected token, expected "," (10:29) ERROR: Unable to parse /home/user/project//dummy-project/interface/DummyInterface.ts: Unexpected reserved word 'interface'. (11:0) ERROR: Unable to parse /home/user/project//dummy-project/interface/OtherInterface.ts: Unexpected reserved word 'interface'. (11:0) ERROR: Unable to parse /home/user/project//dummy-project/interface/ParentInterface.ts: Unexpected reserved word 'interface'. (7:0) ERROR: Unable to parse /home/user/project//dummy-project/typedef/DummyTypedef.ts: Missing semicolon. (6:4) /home/user/project//node_modules/child-process-promise/lib/index.js:132 var err = new ChildProcessError(message, code, cp); ^ ChildProcessError: `npx @daybrush/jsdoc -X -r -c ./jsdoc.json -d /tmp/tmp-80634-B6rkSgdVc3Ye` failed with code 1 at ChildProcess. (/home/user/project//node_modules/child-process-promise/lib/index.js:132:23) at ChildProcess.emit (node:events:513:28) at maybeClose (node:internal/child_process:1091:16) at ChildProcess._handle.onexit (node:internal/child_process:302:5) { code: 1, childProcess: ChildProcess { _events: [Object: null prototype] { error: [Function (anonymous)], close: [Function (anonymous)] }, _eventsCount: 2, _maxListeners: undefined, _closesNeeded: 3, _closesGot: 3, connected: false, signalCode: null, exitCode: 1, killed: false, spawnfile: 'npx', _handle: null, spawnargs: [ 'npx', '@daybrush/jsdoc', '-X', '-r', '-c', './jsdoc.json', '-d', '/tmp/tmp-80634-B6rkSgdVc3Ye' ], pid: 80645, stdin: Socket { connecting: false, _hadError: false, _parent: null, _host: null, _closeAfterHandlingError: false, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: [], flowing: null, ended: true, endEmitted: true, reading: false, constructed: true, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: false, autoDestroy: true, destroyed: true, errored: null, closed: true, closeEmitted: true, defaultEncoding: 'utf8', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: false, decoder: null, encoding: null, readable: false, [Symbol(kPaused)]: null }, _events: [Object: null prototype] { end: [Function: onReadableStreamEnd] }, _eventsCount: 1, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: true, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: true, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, buffered: [], bufferedIndex: 0, allBuffers: true, allNoop: true, pendingcb: 0, constructed: true, prefinished: false, errorEmitted: false, emitClose: false, autoDestroy: true, errored: null, closed: true, closeEmitted: true, [Symbol(kOnFinished)]: [] }, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null, [Symbol(async_id_symbol)]: 8, [Symbol(kHandle)]: null, [Symbol(lastWriteQueueSize)]: 0, [Symbol(timeout)]: null, [Symbol(kBuffer)]: null, [Symbol(kBufferCb)]: null, [Symbol(kBufferGen)]: null, [Symbol(kCapture)]: false, [Symbol(kSetNoDelay)]: false, [Symbol(kSetKeepAlive)]: false, [Symbol(kSetKeepAliveInitialDelay)]: 0, [Symbol(kBytesRead)]: 0, [Symbol(kBytesWritten)]: 0 }, stdout: Socket { connecting: false, _hadError: false, _parent: null, _host: null, _closeAfterHandlingError: false, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: [], flowing: false, ended: true, endEmitted: true, reading: false, constructed: true, sync: false, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: false, autoDestroy: true, destroyed: true, errored: null, closed: true, closeEmitted: true, defaultEncoding: 'utf8', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: true, decoder: null, encoding: null, [Symbol(kPaused)]: true }, _events: [Object: null prototype] { end: [Function: onReadableStreamEnd], close: [Function (anonymous)] }, _eventsCount: 2, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: true, needDrain: false, ending: true, ended: true, finished: true, destroyed: true, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, buffered: [], bufferedIndex: 0, allBuffers: true, allNoop: true, pendingcb: 0, constructed: true, prefinished: true, errorEmitted: false, emitClose: false, autoDestroy: true, errored: null, closed: true, closeEmitted: true, [Symbol(kOnFinished)]: [] }, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null, write: [Function: writeAfterFIN], [Symbol(async_id_symbol)]: 9, [Symbol(kHandle)]: null, [Symbol(lastWriteQueueSize)]: 0, [Symbol(timeout)]: null, [Symbol(kBuffer)]: null, [Symbol(kBufferCb)]: null, [Symbol(kBufferGen)]: null, [Symbol(kCapture)]: false, [Symbol(kSetNoDelay)]: false, [Symbol(kSetKeepAlive)]: false, [Symbol(kSetKeepAliveInitialDelay)]: 0, [Symbol(kBytesRead)]: 4605, [Symbol(kBytesWritten)]: 0 }, stderr: Socket { connecting: false, _hadError: false, _parent: null, _host: null, _closeAfterHandlingError: false, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: [], flowing: false, ended: true, endEmitted: true, reading: false, constructed: true, sync: false, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: false, autoDestroy: true, destroyed: true, errored: null, closed: true, closeEmitted: true, defaultEncoding: 'utf8', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: true, decoder: null, encoding: null, [Symbol(kPaused)]: true }, _events: [Object: null prototype] { end: [Function: onReadableStreamEnd], close: [Function (anonymous)] }, _eventsCount: 2, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: true, needDrain: false, ending: true, ended: true, finished: true, destroyed: true, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, buffered: [], bufferedIndex: 0, allBuffers: true, allNoop: true, pendingcb: 0, constructed: true, prefinished: true, errorEmitted: false, emitClose: false, autoDestroy: true, errored: null, closed: true, closeEmitted: true, [Symbol(kOnFinished)]: [] }, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null, write: [Function: writeAfterFIN], [Symbol(async_id_symbol)]: 10, [Symbol(kHandle)]: null, [Symbol(lastWriteQueueSize)]: 0, [Symbol(timeout)]: null, [Symbol(kBuffer)]: null, [Symbol(kBufferCb)]: null, [Symbol(kBufferGen)]: null, [Symbol(kCapture)]: false, [Symbol(kSetNoDelay)]: false, [Symbol(kSetKeepAlive)]: false, [Symbol(kSetKeepAliveInitialDelay)]: 0, [Symbol(kBytesRead)]: 1250, [Symbol(kBytesWritten)]: 0 }, stdio: [ Socket { connecting: false, _hadError: false, _parent: null, _host: null, _closeAfterHandlingError: false, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: [], flowing: null, ended: true, endEmitted: true, reading: false, constructed: true, sync: true, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: false, autoDestroy: true, destroyed: true, errored: null, closed: true, closeEmitted: true, defaultEncoding: 'utf8', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: false, decoder: null, encoding: null, readable: false, [Symbol(kPaused)]: null }, _events: [Object: null prototype] { end: [Function: onReadableStreamEnd] }, _eventsCount: 1, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: true, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: true, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, buffered: [], bufferedIndex: 0, allBuffers: true, allNoop: true, pendingcb: 0, constructed: true, prefinished: false, errorEmitted: false, emitClose: false, autoDestroy: true, errored: null, closed: true, closeEmitted: true, [Symbol(kOnFinished)]: [] }, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null, [Symbol(async_id_symbol)]: 8, [Symbol(kHandle)]: null, [Symbol(lastWriteQueueSize)]: 0, [Symbol(timeout)]: null, [Symbol(kBuffer)]: null, [Symbol(kBufferCb)]: null, [Symbol(kBufferGen)]: null, [Symbol(kCapture)]: false, [Symbol(kSetNoDelay)]: false, [Symbol(kSetKeepAlive)]: false, [Symbol(kSetKeepAliveInitialDelay)]: 0, [Symbol(kBytesRead)]: 0, [Symbol(kBytesWritten)]: 0 }, Socket { connecting: false, _hadError: false, _parent: null, _host: null, _closeAfterHandlingError: false, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: [], flowing: false, ended: true, endEmitted: true, reading: false, constructed: true, sync: false, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: false, autoDestroy: true, destroyed: true, errored: null, closed: true, closeEmitted: true, defaultEncoding: 'utf8', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: true, decoder: null, encoding: null, [Symbol(kPaused)]: true }, _events: [Object: null prototype] { end: [Function: onReadableStreamEnd], close: [Function (anonymous)] }, _eventsCount: 2, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: true, needDrain: false, ending: true, ended: true, finished: true, destroyed: true, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, buffered: [], bufferedIndex: 0, allBuffers: true, allNoop: true, pendingcb: 0, constructed: true, prefinished: true, errorEmitted: false, emitClose: false, autoDestroy: true, errored: null, closed: true, closeEmitted: true, [Symbol(kOnFinished)]: [] }, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null, write: [Function: writeAfterFIN], [Symbol(async_id_symbol)]: 9, [Symbol(kHandle)]: null, [Symbol(lastWriteQueueSize)]: 0, [Symbol(timeout)]: null, [Symbol(kBuffer)]: null, [Symbol(kBufferCb)]: null, [Symbol(kBufferGen)]: null, [Symbol(kCapture)]: false, [Symbol(kSetNoDelay)]: false, [Symbol(kSetKeepAlive)]: false, [Symbol(kSetKeepAliveInitialDelay)]: 0, [Symbol(kBytesRead)]: 4605, [Symbol(kBytesWritten)]: 0 }, Socket { connecting: false, _hadError: false, _parent: null, _host: null, _closeAfterHandlingError: false, _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: null, tail: null, length: 0 }, length: 0, pipes: [], flowing: false, ended: true, endEmitted: true, reading: false, constructed: true, sync: false, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: false, autoDestroy: true, destroyed: true, errored: null, closed: true, closeEmitted: true, defaultEncoding: 'utf8', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: true, decoder: null, encoding: null, [Symbol(kPaused)]: true }, _events: [Object: null prototype] { end: [Function: onReadableStreamEnd], close: [Function (anonymous)] }, _eventsCount: 2, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: true, needDrain: false, ending: true, ended: true, finished: true, destroyed: true, decodeStrings: false, defaultEncoding: 'utf8', length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, buffered: [], bufferedIndex: 0, allBuffers: true, allNoop: true, pendingcb: 0, constructed: true, prefinished: true, errorEmitted: false, emitClose: false, autoDestroy: true, errored: null, closed: true, closeEmitted: true, [Symbol(kOnFinished)]: [] }, allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: null, _server: null, write: [Function: writeAfterFIN], [Symbol(async_id_symbol)]: 10, [Symbol(kHandle)]: null, [Symbol(lastWriteQueueSize)]: 0, [Symbol(timeout)]: null, [Symbol(kBuffer)]: null, [Symbol(kBufferCb)]: null, [Symbol(kBufferGen)]: null, [Symbol(kCapture)]: false, [Symbol(kSetNoDelay)]: false, [Symbol(kSetKeepAlive)]: false, [Symbol(kSetKeepAliveInitialDelay)]: 0, [Symbol(kBytesRead)]: 1250, [Symbol(kBytesWritten)]: 0 } ], [Symbol(kCapture)]: false }, stdout: undefined, stderr: undefined } Node.js v18.12.1 ```
WoodNeck commented 1 year ago

Looks like a dependency collision with Docusarus. Try putting dummy-project and configs outside of the Docusaurus folder and run script there

root <- run script here
ㄴ docs (Docusaurus root)
ㄴ dummy_project
ㄴ jsdoc.json
ㄴ config.json
selankon commented 1 year ago

Thats ok, I got dummy-project documentation generated. Thanks

selankon commented 1 year ago

I Is there a way to avoid dependency collisions? The project I have to generate seems to have a dependency collision also. Is not a docusaurus project, and after do yarn, with all dependencies downloaded, If i run the build docs it throws lots of errors like that.

selankon commented 1 year ago

I guess this is not a dependency collision. From a standalone, if I use yarn and not npm, it breaks with same error

elboletaire commented 1 year ago

I'm also facing with this issue RN, there's no way to run jsdoc-to-mdx with yarn in this project: https://github.com/vocdoni/vocdoni-sdk/tree/main/docs

It works without any issue when using npm. I ensured both lockfiles are exactly the same (by using yarn import), and it just crashes with yarn, while doing it with npm works as expected. Note that it crashes running the process, but the failure comes from installing wrong dependencies; meaning if I run npm i and then run the script with yarn run script it'll work, the problem lies with the installation of dependencies using yarn, then running jsdoc-to-mdx with whatever you run it (either npx, or yarn, both fail).

Is a typescript project, as the one from the OP, and I'm also storing my docs project inside a docs folder in the main repo.

Haven't tried what you say about moving scripts outside, I'd prefer not to do so, since it would mean adding dependencies outside that I don't want at all for the main project.

Personally I never faced with an issue like this before... I've been working with yarn since the very first day (+6 years now if I'm not wrong), and never faced an issue with dependencies being installed in different ways depending on the package manager used (running from the same json file, ofc).

Any ideas?

WoodNeck commented 1 year ago

Maybe the command npx used internally broke in this case I guess? I was quite busy so I couldn't, but I'll take a look at it & fix it right now.


Also, quick notice for those who are interested in this project: As jsdoc itself lacks compatibility with Typescript-only features like generics, etc. We're making a new document generator, which uses TypeDoc instead. It's WIP, but you can take a sneak peek at it:

Ideas/PRs welcome!

Don't worry, both projects(this repo and the new one) will be maintained :)

WoodNeck commented 1 year ago

Released a new beta version that might fix this issue, at least for my env. Try installing jsdoc-to-mdx@1.1.3-beta.0, it will be released if it's okay after PR.

elboletaire commented 1 year ago

Awesome @WoodNeck. TBH I won't be able to try it until next year already, since I'm out on vacation. Hopefully the OP could test it before 😅

selankon commented 1 year ago

Yey have you any ideas when an stable release of typedoc-to-mdx will be stable?

I tried jsdoc-to-mdx@1.1.3-beta.0 and now yarn works good! Thanks!

WoodNeck commented 1 year ago

@selankon typedoc-to-mdx will be released soon, maybe in January next year :)

But here are things you should consider, as it's in development stage:

WoodNeck commented 1 year ago

Fixed in jsdoc-to-mdx@1.1.3

selankon commented 1 year ago

Hi @WoodNeck any updates with your awesome typedoc-to-mdx??

Thanks in advance

WoodNeck commented 1 year ago

@selankon That can be released within the next week. But the problem is, I have so many works to do right now so two things will be missing.

I'll leave a comment here after releasing it :)

selankon commented 1 year ago

Thats really nice. Just ping us when released and we will test it :)

WoodNeck commented 1 year ago

@selankon typedoc-to-mdx is released!

Feedback is welcomed! It's a project I made in a hurry so that weird things might happen in your env. Please leave the issue on the project GitHub if anything happens.

selankon commented 1 year ago

Yey! Great news! Will test it asap!