Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate jsdoc documentation

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

View of generate documentation

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

like image 449
Carman Avatar asked Mar 11 '23 12:03

Carman


1 Answers

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

like image 65
Harry Moreno Avatar answered Mar 20 '23 15:03

Harry Moreno