nanopx / gulp-esdoc

Gulp plugin for ESDoc
11 stars 11 forks source link

please support config file. #14

Open liu946 opened 8 years ago

liu946 commented 8 years ago

the .esdocrc file can use in esdoc module. I didn't find a way to use config-file way in gulp-esdoc.

liu946 commented 8 years ago

I have checked your code and find that config file is 'path/to/dir/esdoc.json'. please use the input string user-defined path instead when config is a STRING.

ghost commented 7 years ago

So the solution is to require your config file like so const esdocConfig = require( "./path/to/dir/esdoc.json" ); then: gulp.src(["./src"]).pipe( esDoc( esdocConfig ) ); Should do it!

colbin8r commented 7 years ago

This plugin supports ESDoc config file. The real issue is in the name of the file it looks for: tt should look for .esdoc.json as stated by the docs, but instead looks for a esdoc.json file.

ESDoc automatically finds the configuration file path by the order, if you don't specify -c esdoc.json.

  1. .esdoc.json in the current directory
  2. .esdoc.js in the current directory
  3. esdoc property in package.json

In the meantime, you could do something like this ES6 code, which I myself use:

let esdocConfigPath = path.join(process.cwd(), '.esdoc.json'), data, esdocConfig;
if (fs.existsSync(esdocConfigPath)) {
  data = fs.readFileSync(esdocConfigPath, { encoding: 'utf8' });
  esdocConfig = !data ? {} : JSON.parse(data);
  console.log('Found ESDoc config in .esdoc.json!');
} else {
  esdocConfig  = {};
}