Generate jsdoc documentation

末鹿安然 提交于 2019-12-10 17:15:07

问题


I search to understand how operate jsdoc, the generator of javascript documentation. When I use it, I have always all my documentation files on index.js and never the navigation (in the documentation web site) in my files, classes or modules. Furthermore, I have also some tags which do not appear in the documentation. However, I use just the tags given by usejsdoc web site (documentation of jsdoc).

Version :

  • Node.js : 6.9.1
  • jsdoc : 3.4.2

Server.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'),

I hope you can help me.

Best regards


回答1:


I add jsdocs to typical javascript project by adding a script to package.json

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

and add a config file .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
  }
}

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

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

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



来源:https://stackoverflow.com/questions/40899849/generate-jsdoc-documentation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!