生成jsdoc文档

Car*_*man 4 javascript node.js jsdoc

我搜索了解如何操作jsdoc,javascript文档的生成器。当我使用它时,我总是将所有文档文件放在 index.js 上,而从不在我的文件、类或模块中导航(在文档网站中)。此外,我还有一些没有出现在文档中的标签。但是,我只使用 usejsdoc 网站(jsdoc 的文档)给出的标签。

版本 :

  • 节点.js:6.9.1
  • jsdoc:3.4.2

生成文档视图

服务器.js

"use strict";
/**
 * @module server
 * @file
 * The main file of this server. It create access routes. To use it, you can write on a terminal : $ node server.js                                 <br />
 * Turn in javascript strict mode.                                                                                                                  <br />
 * 
 * @version    1.0
 * @since      1.0
 *
 * @requires config
 * @requires express
 * @requires body-parser
 * @requires messenger.scenario
 * @requires messenger.routeMessenger
 */
const 
    // Official libraries
    /**
     * @access        public
     * @constant
     * @description   Use config file to param server.
     */
    config       =   require("config"),
    express      =   require('express'),
    bodyParser   =   require('body-parser'),
Run Code Online (Sandbox Code Playgroud)

我希望你能帮助我。

此致

Har*_*eno 6

我通过向典型的 javascript 项目添加脚本来将 jsdocs 添加到 package.json

"scripts": {
  ...
  "docs": "./node_modules/jsdoc/jsdoc.js -c ./.jsdoc.conf.json"
}
Run Code Online (Sandbox Code Playgroud)

并添加一个配置文件 .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
  }
}
Run Code Online (Sandbox Code Playgroud)

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

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

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