0

In a terminal, I run the following commands:

$ node sample.js
hello, Stephen MC
$ node_modules/.bin/jsdoc --version
JSDoc 3.3.3 (Tue, 22 Sep 2015 23:14:17 GMT)
$ node_modules/.bin/jsdoc -c jsdocConf.json
Parsing /**/sample.js ...ERROR: Unable to parse /**/sample.js: Line 14: Unexpected token ILLEGAL
complete.
Generating output files...complete.
Finished running in 0.29 seconds.

My sample.js file looks like this:

/** @module myjsdoc/sample */

"use strict";

const me = "Stephen MC";

/** This function logs the parameter.
 * @param {string} param - The string to log.
 */
const myFunc = function ( param ) {
  console.log( param );
};

myFunc( `hello, ${me}` );

My conf.json for jsdoc looks like this:

{
    "tags": {
        "allowUnknownTags": true,
        "dictionaries": ["jsdoc","closure"]
    },
    "source": {
        "include": [ "./" ],
        "exclude": [ "documentation", "node_modules" ],
        "includePattern": ".+\\.js(doc)?$",
        "excludePattern": "(^|\\/|\\\\)_|.+[Ss]pec\\.js"
    },
    "templates": {
        "cleverLinks": false,
        "monospaceLinks": false
    },
    "opts": {
      "destination": "./documentation/",
      "readme": "./README.md",
      "recurse": true,
      "verbose": true
    }
}

Is there any way to configure jsdoc 3.3.3 to tolerate ES6 template strings? Perhaps there is a plugin that might work?

  • 1
    A simple Google search for `jsdoc es6` lead me to https://github.com/jsdoc3/jsdoc/issues/555#issuecomment-124713014 . – Felix Kling Oct 19 '15 at 00:31

2 Answers2

1

jsdoc in master branch uses different parser, which handles es6 better:

npm install git+https://github.com/jsdoc3/jsdoc.git

works nicely for me, I'll switch back with release of version 3.4.0

Adam Popkiewicz
  • 105
  • 1
  • 5
  • Great answer! No more warning messages and it is awesome. Additionally, I learned how to use git directly with npm. I added --save-dev and it is even better. – Stephen MC Oct 21 '15 at 23:10
0

By installing esprima 2.6.0 with npm install and copying that directory from node_modules/esprima to node_modules/jsdoc/node_modules/esprima (overwriting the outdated 1.2.6 esprima version) jsdoc was able to parse the ` marks with just a warning.

I understand jumping from v1 to v2 of esprima is across a breaking change, but it gets the job done for me.