最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Generate jsdoc documentation - Stack Overflow

programmeradmin0浏览0评论

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

How do I generate the JSDoc documentation from my code?

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

How do I generate the JSDoc documentation from my code?

Share Improve this question edited Jul 21, 2023 at 21:48 ruffin 17.5k10 gold badges96 silver badges149 bronze badges asked Nov 30, 2016 at 23:00 CarmanCarman 411 silver badge3 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 8

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/about-configuring-jsdoc.html

发布评论

评论列表(0)

  1. 暂无评论