【问题标题】:Generating JSDoc Documentation on React 18 Project with @component使用@component 生成 React 18 项目的 JSDoc 文档
【发布时间】:2022-12-06 23:52:45
【问题描述】:

我正在尝试为 React 18 项目设置带有更好文档的 JSDoc,以便我可以使用 @component 装饰器记录我的组件。

当我尝试安装 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

有没有人遇到过这个问题?有没有办法让 JSDoc 与 React 18 一起工作?我真的不想为了处理文档而降级反应版本。如果没有办法解决这个问题,我可以使用更好的文档生成包吗?

在 package.json 中,我将文档脚本定义为 "docs": "jsdoc -c 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": "..."
                }
            ]
        }
    }
}

`

如上所述,我尝试使用 --legacy-peer-deps 选项安装 better-docs。当我运行npm run docs 时,没有构建文件生成到 >spec 中,也没有生成 entry.js 文件。我可以通过浏览器查看 global.html 文件来查看文档,但是任何带有 @component 装饰器的文件都不会显示在任何地方。

【问题讨论】:

    标签: reactjs jsdoc react-18


    【解决方案1】:

    只需运行 npm install --legacy-peer-deps 你有问题,你的反应 18 太新了,更好的文档仍然依赖反应 17

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-03-04
      • 1970-01-01
      • 1970-01-01
      • 2018-03-09
      • 1970-01-01
      • 1970-01-01
      • 2021-01-12
      • 1970-01-01
      相关资源
      最近更新 更多