提问人:user6329530 提问时间:11/16/2023 最后编辑:user6329530 更新时间:11/16/2023 访问量:22
如何在我的 React 应用程序中获取 JSDoc 解析功能组件?
How do I get JSDoc parse functional components in my React app?
问:
我有一个更大的 React 应用程序,我尝试使用 JSdoc 记录它。
我有一个类组件,可以正确解析。类 JSDoc 块以及每个类方法。但是,在功能组件(所有其他组件)上,它根本无法解析它们。
它解析每个组件顶部的 JSDoc 块,但不会进入函数来解析函数组件中每个函数上的 JSDoc 块,也不会解析钩子上的 JSDoc 块。
在每个功能组件上,它无法识别 JSXFragments,调试报告错误:
DEBUG: Found a node with unrecognized type JSXFragment. Ignoring the node and its descendants.
我尝试了几次使用 和 .@returns {JSX.Element}
@returns {ReactNode}
我发现一篇博客文章说,他们使用完全无功能的组件在 Redux 中执行所有逻辑。但是我不使用 Redux,我使用 useContext 做所有事情。这是有历史原因的,我宁愿不想为了让 JSDoc 工作而使用 Redux 甚至 useReducer 重构整个项目。
JSDoc 4.0.2 (Sun, 19 Feb 2023 23:01:18 GMT)
jsdoc.json
{
"source": {
"include": ["src", "src/components", "src/context"],
"exclude": ["node_modules", "build", "dist"]
},
"plugins": [
"plugins/markdown"
],
"opts": {
"template": "./node_modules/minami",
"destination": "./docs",
"encoding": "utf8"
},
"templates": {
"cleverLinks": true,
"monospaceLinks": true
},
"jsx": {
"pragma": "JSX"
}
}
答: 暂无答案
评论