我搜索了解如何操作 jsdoc,javascript 文档的生成器。当我使用它时,我的所有文档文件总是在 index.js 上,而我的文件、类或模块中从来没有导航(在文档网站中)。此外,我还有一些没有出现在文档中的标签。但是,我只使用 usejsdoc 网站 ( documentation of jsdoc ) 提供的标签。
版本:
- Node.js:6.9.1
- js文档: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'),
我希望你能帮助我。
最好的问候
最佳答案
我通过将脚本添加到 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
中生成文档。
然后您可以通过运行 npm run docs
生成项目文档。
您可能还想忽略生成的文档。有关完整的配置选项,请阅读 http://usejsdoc.org/about-configuring-jsdoc.html
关于javascript - 生成jsdoc文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40899849/