generator

  • typedef
documentjs.generator

{function(docMapPromise, The)}

 

A generator module should produce a function that takes the following shape. Generator modules are used to produce some form of documentation output. generators.html is the default and currently only generator packaged with DocumentJS.

function(docMapPromise, The)

Parameters

  1. docMapPromise {Promise<docMap>}

    A promise that will resolve with a map of all docObjects keyed by their name.

  2. The {options}

    options object passed to generate.

Returns

{Promise}

A module that resolves when the output has been built.

Use

The following exports a generator function that builds a JSON output of the docObject:

var Q = require('q'),
    fs = require('fs'),
    writeFile = Q.denodify(fs.writeFile),
    path = require('path');
    
module.exports = function(docMapPromise, options){
   return docMapPromise.then(function(docMap){
     return writeFile(
         path.join(options.dest,'docMap.json'), 
         JSON.stringify(docMap) );
   });
};