javascript - 生成jsdoc文档

标签 javascript node.js jsdoc

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

版本:

  • Node.js:6.9.1
  • js文档:3.4.2

View of generate documentation

服务器.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'),

我希望你能帮助我。

最好的问候

最佳答案

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

来将 jsdocs 添加到典型的 javascript 项目中
"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 中生成文档。

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

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

关于javascript - 生成jsdoc文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40899849/

相关文章:

javascript - 如何使用 JSDoc 注释 Express 中间件?

javascript - ReactJS 0.14 - 使用 promise

json - 有没有办法不向任何人显示 API 的 JSON 响应?

javascript - 将函数应用于 MongoDB 集合中的所有对象的最有效方法是什么?

用于接口(interface)属性的 TypeScript jsdoc

javascript - 使用 JSDoc 我将如何注释一个解构的重命名函数参数?

javascript - Ngfor 对象列表并从主数组中的对象之一内的数组再次循环

javascript - 为什么 'await'不等待?

javascript - 为什么这个模块不打印

node.js - 使用 node-postgres 查询 postgres 数据库