Search code examples
jsdoc

JSDoc: Lookup tutorials from different directories


Is there a way to ask JSDoc (either in the command line or through grunt-jsdoc plugin) to lookup tutorials from different directories ?

As per the documentation, -u allows to specify the Directory in which JSDoc should search for tutorials. (it says the Directory instead of Directories).

I tried the following with no luck:

  • specify different strings separated by space or comma
  • specify one string with shell/ant regular expression

Solution

  • As suggested by @Vasil Vanchuk, a solution would be creating links to all tutorial files within a single directory. As such, JSDoc3 will be happy and it will proceed with the generation of all tutorials.

    Creating/maintaining links manually would be a tedious task. Hence, and for people using grunt, the grunt-contrib-symlink come in handy. Using this plugin, the solution is reduced to a config task.

    My Gruntfile.js looks like the following:

    clean:['tmp', 'doc'],
    
    symlink: {
        options: {
            overwrite: false,
        },
        tutorials: {
            files: [{
                cwd: '../module1/src/main/js/tut',
                dest: 'tmp/tutorial-generation-workspace',
                expand: true,
                src: ['*'],
            }, {
                cwd: '../module2/src/main/js/tut',
                dest: 'tmp/tutorial-generation-workspace',
                expand: true,
                src: ['*'],
            }]
        }
    },
    
    jsdoc: {
        all: {
            src: [
                '../module1/src/main/js/**/*.js',
                '../module2/src/main/js/**/*.js',
                './README.md',
            ],
            options: {
                destination: 'doc',
                tutorials: 'tmp/tutorial-generation-workspace',
                configure : "jsdocconf.json",
                template: 'node_modules/grunt-jsdoc/node_modules/ink-docstrap/template',
            },
        }
    },
    
    grunt.loadNpmTasks('grunt-contrib-symlink');
    grunt.loadNpmTasks('grunt-jsdoc');
    
    grunt.registerTask('build', ['clean', 'symlink', 'jsdoc']);
    grunt.registerTask('default', ['build']);
    

    Integrating new module is translated by updating symlink and jsdoc tasks.