jsdoc-api icon indicating copy to clipboard operation
jsdoc-api copied to clipboard

Explicitly setting pedantic to false generates error

Open ripperdoc opened this issue 4 years ago • 5 comments

As I experimented with JSDoc API, I tried the following code:

const jsdoc = require('jsdoc-api')
jsdoc.explainSync({files: 'functions/engine/scenarios.js', pedantic: false});

Unfortunately, that throws an error, where it seems as if false has been mistaken for a path.

/Users/martin/dev/src/fictive-tools/node_modules/jsdoc-api/lib/jsdoc-command.js:114
      throw err
      ^

JSDOC_ERROR: ERROR: Unable to find the source file or directory /Users/martin/dev/src/fictive-tools/false
    at ExplainSync.verifyOutput (/Users/martin/dev/src/fictive-tools/node_modules/jsdoc-api/lib/jsdoc-command.js:112:19)
    at ExplainSync._runJsdoc (/Users/martin/dev/src/fictive-tools/node_modules/jsdoc-api/lib/explain-sync.js:34:32)
    at ExplainSync.getOutput (/Users/martin/dev/src/fictive-tools/node_modules/jsdoc-api/lib/explain-sync.js:17:19)
    at ExplainSync.execute (/Users/martin/dev/src/fictive-tools/node_modules/jsdoc-api/lib/jsdoc-command.js:49:24)
    at Object.explainSync (/Users/martin/dev/src/fictive-tools/node_modules/jsdoc-api/index.js:20:18)
    at Object.<anonymous> (/Users/martin/dev/src/fictive-tools/test.js:2:7)
    at Module._compile (internal/modules/cjs/loader.js:1185:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
    at Module.load (internal/modules/cjs/loader.js:1034:32)
    at Function.Module._load (internal/modules/cjs/loader.js:923:14)

Calling with true works, however.

Thanks, Martin

ripperdoc avatar Jun 18 '20 13:06 ripperdoc

hi, thanks for the report.. in your project's node_modules folder, please put console.log(jsdocArgs) above this line and post the output 👍

thanks!

75lb avatar Jun 18 '20 13:06 75lb

Sure, that outputs:

[
  '/Users/martin/dev/src/fictive-tools/node_modules/jsdoc/jsdoc.js',
  '--pedantic',
  'false',
  '-X',
  'functions/engine/scenarios.js'
]

I think it's because --pedantic is a flag in JSdoc CLI, so if it exists, its true, if it doesn't exist, it's false.

ripperdoc avatar Jun 18 '20 13:06 ripperdoc

OK, yes you're probably right - i'll take a look.. does your documentation generate correctly when not using pedantic mode?

75lb avatar Jun 18 '20 13:06 75lb

So far I'm not generating docs but using the explain only to produce a CLI. I can run without setting pedantic and it's working, so I can manage.

ripperdoc avatar Jun 18 '20 13:06 ripperdoc

ok, glad you can manage for now.. will have a look this evening

75lb avatar Jun 18 '20 13:06 75lb