Open thomas-robotham opened 1 year ago
Hello, @thomas-robotham
Looks like the jsdoc.json
file is missing, try adding one with the correct include
settings.
This module is designed to render your jsdoc comments into .mdx(markdown + JSX) format.
The main use case we're supposing is to build API documents for your Javascript/Typescript module.
So, basically, as this module automates that process, you can't directly transform your .js
file into .mdx
. The input files are managed from jsdoc
config.
If you don't need .mdx
features, like using react components, you can try using jsdoc-to-markdown to render your files as markdown instead.
Yes. This module is meant to be used with Docusarus and is depending on their structure.
locales
and localesDir
generate i18n documents for you if you have a locale-specific comment in your jsdoc.
Like, for example, we're using Korean descriptions like this in our projects.
/**
* Description, in English
* @ko 한글로 된 설명
*/
class SomeClass {}
You can also try using typedoc-to-mdx if you're using Typescript.
Hi @WoodNeck, Thanks for the fast response :D I would like to include some react components on the final .mdx files, so it would be great to use this module.
I included a dummy Docusaurus project under ./docs/
and additonally added a simple jsdoc.json
config file.
Folder structure is now as follow:
parentDir
|---docs
|---|---docs
|---|---docusaurus_stuff
|---|---...
|---config.json
|---jsdoc.json
|---package-lock.json
|---package.json
|---example.js
|---node_modules
The jsdoc.json config is (with the include key simply set to the top level dir, so it should catch the example.js file):
{
"tags": {
"allowUnknownTags" : false,
"dictionaries": ["jsdoc", "closure"]
},
"source": {
"include": ["./"],
"includePattern": ".+\\.(j|t)s(doc|x)?$",
"excludePattern": "(^|\\/|\\\\)_"
}
}
A small step forward as it's picking up the input file... but now i have the following error:
PS D:\work\qoevave\testing_mdx> npx jsdoc-to-mdx -c ./config.json
undefined:1
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at D:\work\qoevave\testing_mdx\node_modules\jsdoc-to-mdx\bin\generate.js:527:22
at Generator.next (<anonymous>)
at fulfilled (D:\work\qoevave\testing_mdx\node_modules\jsdoc-to-mdx\bin\generate.js:55:58)
All my .json files have correct structure, any clues? (thnx for the help)
SyntaxError: Unexpected end of JSON input
happens when the input data is incorrect.
You can try checking:
.json
files are well-formatted: config.json
and jsdoc.json
config.json
should be located in the directory testing_mdx
npx jsdoc-to-mdx -c config.json
instead.No luck. All .json structures are fine and the relative location of the files is correct.
I'll try a completly fresh install in a new directory.
I tried building the project myself with these settings, and looks like it's working fine. Maybe it's Windows/Powershell issue? I never tried building a project in that env.
project structure
npx create-docusaurus@latest demo classic
Docusaurus init
{
"locales": ["ko"],
"outDir": "./demo/docs/api",
"localesDir": "./demo/i18n/{locale}/docusaurus-plugin-content-docs/current/api",
"sidebar": "./demo",
"jsdoc": "./jsdoc.json",
"bulma": false
}
config.json
{
"tags": {
"allowUnknownTags" : true,
"dictionaries": ["jsdoc", "closure"]
},
"source": {
"include": ["src"],
"includePattern": ".+\\.(j|t)s(doc|x)?$",
"excludePattern": "(^|\\/|\\\\)_"
}
}
jsdoc.json
/**
* Description of A
*/
class A {
}
export default A;
src/index.ts
result
Delayed response but back again. So I tried on my Mac M1 and here's the following...
Folder structure
npm installing
jsdoc
, there's no issues.npm installing
jsdoc-to-mdx
there are some critical errors.
Ignoring the errors and trying `npx jsdoc-to-mdx -c config.json will lead to the error we've previously mentioned regarding the .json file (See below again).
npm audit fix leaves you with the following:
If i force update this package this I get the following error.
Have you guys tried installing the packages fresh too?
I've fresh installed the package while testing that. I've also tested on the Apple Silicon chip, so that's not might be the issue. Try the template below, it works in my environment.
@thomas-robotham
The version of jsdoc-to-mdx
was version down while audit
was executed.
Would you like to test the version of jsdoc-to-mdx
again with the latest version?
Try installing @daybrush/jsdoc
manually if you are going to use a downgraded version.
Hello,
Same error for us, the code generation suddenly stops working with the same error when yarn run npx jsdoc-to-mdx -c jsdoc-to-mdx.config.json
:
SyntaxError: Unexpected end of JSON input
I tried to upgrade all the packages without success, currently using the "jsdoc-to-mdx": "^1.2.1"
version.
I tried the https://github.com/WoodNeck/jsdoc-to-mdx-test and it works properly.
"devDependencies": {
"@babel/cli": "^7.19.3",
"@babel/core": "^7.20.5",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@daybrush/jsdoc": "^0.4.5",
"jsdoc-babel": "^0.5.0",
"jsdoc-to-markdown": "^8.0.0",
"jsdoc-to-mdx": "^1.1.3"
}
I tried also the 1.2.1
version of jsdoc-to-mdx
{
"locales": [],
"outDir": "./temp_docs",
"localesDir": "./temp_docs/i18n/{locale}/docusaurus-plugin-content-docs/current/sdk",
"sidebar": "./temp_docs",
"prefix": "sdk/",
"jsdoc": "./jsdoc.json"
}
I tried adding "en"
locale to the locales array.
{
"tags": {
"allowUnknownTags" : true,
"dictionaries": ["jsdoc", "closure"]
},
"source": {
"include": ["../src"],
"exclude": ["../src/dvote-protobuf"],
"includePattern": ".+\\.(j|t)s(doc|x)?$",
"excludePattern": "(^|\\/|\\\\)_"
}
}
No idea why stop working suddenly. Any help will be welcome.
Experiencing this problem also. Digging into it a little SyntaxError: Unexpected end of JSON input
was happening because the temp file was empty and didn't parse as JSON.
The temp file was empty because the forked child process couldn't successfully parse some of our code:
/Users/s/Code/turf-www-span/node_modules/@daybrush/jsdoc/lib/jsdoc/src/parser.js:226
if (this._extras[filename][name].every(function(tsInfo) {
^
TypeError: this._extras[filename][name].every is not a function
Whatever was winding up in this._extras[filename][name]
wasn't what the parser was expecting. Was able to work around the issue by setting recurseDepth to 2 (the file tripping up the parser was a util class several layers deep we didn't need documented). This allowed jsdoc to run all the way through. Didn't investigate much further.
Maybe this will help someone track down the issue in future. Or at least present a workaround.
I have the following file structure:
package.json looks like:
config.json looks like (taken from documenation):
Main issue
There are no input files to process
How can this be reoslved?Additional queries