且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

生成jsdoc文档

更新时间:2023-02-15 16:11:30

我通过将脚本添加到package.json

"scripts": {
  ...
  "docs": "./node_modules/jsdoc/jsdoc.js -c ./.jsdoc.conf.json"
}

并添加配置文件.jsdoc.conf.json

{
  "plugins": [],
  "recurseDepth": 10,
  "opts": {
    "recurse": true,
    "destination": "./docs/"
  },
  "source": {
    "include": ["src"],
    "includePattern": ".+\\.js(doc|x)?$",
    "excludePattern": "node_modules"
  },
  "sourceType": "module",
  "tags": {
    "allowUnknownTags": true,
    "dictionaries": ["jsdoc", "closure"]
  },
  "templates": {
    "cleverLinks": false,
    "monospaceLinks": false
  }
}

这将在项目根目录的./docs文件夹中生成文档.

this generates the docs in a folder ./docs in the root of the project.

然后您可以通过运行npm run docs来生成项目文档.

You can then generate project docs by running npm run docs.

您可能还想gitignore生成的文档.有关完整的配置选项,请阅读 http://usejsdoc.org/about-configuring-jsdoc.html

You may also want to gitignore the generated docs. For full configuration options read http://usejsdoc.org/about-configuring-jsdoc.html