[英]Generating JSDoc Documentation on React 18 Project with @component
I am trying to set up JSDoc with better-docs for a react 18 project so I can document my components with the @component decorator.我正在尝试为 React 18 项目设置带有更好文档的 JSDoc,以便我可以使用 @component 装饰器记录我的组件。
When I try to install better-docs I get the following error: npm ERR: code ERESOLVE npm ERR. ERESOLVE unable to resolve dependency tree npm ERR. npm ERR: While resolving. framework@1.0.0 npm ERR. Found: react@18.2.0 npm ERR. node_modules/react npm ERR. react@"^18.2.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@"^17.0.2" from better-docs@2.7.2
当我尝试安装 better-docs 时出现以下错误: npm ERR: code ERESOLVE npm ERR. ERESOLVE unable to resolve dependency tree npm ERR. npm ERR: While resolving. framework@1.0.0 npm ERR. Found: react@18.2.0 npm ERR. node_modules/react npm ERR. react@"^18.2.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@"^17.0.2" from better-docs@2.7.2
npm ERR: code ERESOLVE npm ERR. ERESOLVE unable to resolve dependency tree npm ERR. npm ERR: While resolving. framework@1.0.0 npm ERR. Found: react@18.2.0 npm ERR. node_modules/react npm ERR. react@"^18.2.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer react@"^17.0.2" from better-docs@2.7.2
Has anyone encountered this issue before?有没有人遇到过这个问题? Is there a way to get JSDoc working with React 18?有没有办法让 JSDoc 与 React 18 一起工作? I don't really want to downgrade react version just to handle documentation.我真的不想为了处理文档而降级反应版本。 If there's not a way around this are there any better documentation generation packages I can use?如果没有办法解决这个问题,我可以使用更好的文档生成包吗?
In package.json I have defined the docs script as "docs": "jsdoc -c jsdoc.conf.json
在 package.json 中,我将文档脚本定义为"docs": "jsdoc -c jsdoc.conf.json
And here is my jsdoc.conf.json: `这是我的 jsdoc.conf.json:`
{
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc"]
},
"plugins": [
"plugins/markdown",
"node_modules/better-docs/typescript",
"node_modules/better-docs/component"
],
"opts": {
"destination": "spec/docs",
"encoding": "utf8",
"readme": "README.md",
"recurse": true,
"verbose": true,
"template": "./node_modules/better-docs"
},
"source": {
"include": [ "./src" ],
"exclude": [ "./src/**/*.text,tsx", "./src/**/*.test.ts" ],
"includePattern": "\\.(jsx|js|ts|tsx)$",
"excludePattern": "(^|\\/|\\\\)_"
},
"templates": {
"cleverLinks": false,
"monospaceLinks": false,
"search": true,
"better-docs": {
"name": "framework documentation",
"title": "Framework Documentation",
"hideGenerator": false,
"navLinks": [
{
"label": "Respository",
"href": "..."
}
]
}
}
}
` `
As mentioned above I tried installing better-docs with the --legacy-peer-deps option.如上所述,我尝试使用 --legacy-peer-deps 选项安装 better-docs。 When I run npm run docs
no build file is generated into >spec, and no entry.js file is generated.当我运行npm run docs
时,没有构建文件生成到 >spec 中,也没有生成 entry.js 文件。 I can view the docs by viewing the global.html file from my browser, but any files with the @component decorator are not displayed anywhere.我可以通过浏览器查看 global.html 文件来查看文档,但是任何带有 @component 装饰器的文件都不会显示在任何地方。
Just run赶紧跑
npm install --legacy-peer-deps
you have the problem, that your react 18 is too new and better-docs rely on react 17 still你有问题,你的反应 18 太新了,更好的文档仍然依赖反应 17
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.