I'm trying to watch some files in a directory and automatically update there documentation with jsdoc. I use gulp to watch the file and run jsdoc see code below.
const gulp = require('gulp');
const watch = require('gulp-watch');
const jsdoc = require('gulp-jsdoc3');
gulp.task('doc', function(cb) {
const config = require('./jsdoc.json');
return watch(['../upload/**/*.js'], { ignoreInitial: false })
.pipe(jsdoc(config, cb));
});
When I run this task it doesn't update my jsdoc when a file is changed. Does jsdoc not work together with the watch function?
It´s not sure that the problem comes from gulp-jsdoc3. Maybe you want to split your task into two tasks.
for the watcher
const gulp = require('gulp');
const watch = require('gulp-watch');
const jsdoc = require('gulp-jsdoc3');
gulp.task('jsdoc-task', function() {
console.log('task is running')
const config = require('./jsdoc.json');
return gulp.src( 'scr/files' )
.pipe(jsdoc(config)).
.pipe(gulp.dest( 'your destination path ));
});
gulp.task('watch', function() {
gulp.watch('files-to-watch', [jsdoc-task]);
});
Please note there is no return
for the watcher and also the files to watch
src should not be the same as the output destination files.
You can now see the consol.log
and check out if the task was started.
Now it should be easier to find out whats going wrong. If it´s not working check out the error message for more details.