lib/output/generateBook.js
function generateBook(generator, book, options) {
    options = generator.Options(options);
    var state = generator.State? generator.State({}) : Immutable.Map();
    var start = Date.now();

    return Promise(
        new Output({
            book: book,
            options: options,
            state: state,
            generator: generator.name
        })
    )

    // Cleanup output folder
    .then(function(output) {
        var logger = output.getLogger();
        var rootFolder = output.getRoot();

        logger.debug.ln('cleanup folder "' + rootFolder + '"');
        return fs.ensureFolder(rootFolder)
            .thenResolve(output);
    })

    .then(processOutput.bind(null, generator))

    // Log duration and end message
    .then(function(output) {
        var logger = output.getLogger();
        var end = Date.now();
        var duration = (end - start)/1000;

        logger.info.ok('generation finished with success in ' + duration.toFixed(1) + 's !');

        return output;
    });
}
function generateBook(generator, book, options) {
    options = generator.Options(options);
    var state = generator.State? generator.State({}) : Immutable.Map();
    var start = Date.now();

    return Promise(
        new Output({
            book: book,
            options: options,
            state: state,
            generator: generator.name
        })
    )

    // Cleanup output folder
    .then(function(output) {
        var logger = output.getLogger();
        var rootFolder = output.getRoot();

        logger.debug.ln('cleanup folder "' + rootFolder + '"');
        return fs.ensureFolder(rootFolder)
            .thenResolve(output);
    })

    .then(processOutput.bind(null, generator))

    // Log duration and end message
    .then(function(output) {
        var logger = output.getLogger();
        var end = Date.now();
        var duration = (end - start)/1000;

        logger.info.ok('generation finished with success in ' + duration.toFixed(1) + 's !');

        return output;
    });
}
function generateBook ( generator , book , options ) { options = generator . Options ( options ) ; var state = generator . State ? generator . State ( { } ) : Immutable . Map ( ) ; var start = Date . now ( ) ; return Promise ( new Output ( { book : book , options : options , state : state , generator : generator . name } ) ) // Cleanup output folder . then ( function ( output ) { var logger = output . getLogger ( ) ; var rootFolder = output . getRoot ( ) ; logger . debug . ln ( 'cleanup folder "' + rootFolder + '"' ) ; return fs . ensureFolder ( rootFolder ) . thenResolve ( output ) ; } ) . then ( processOutput . bind ( null , generator ) ) // Log duration and end message . then ( function ( output ) { var logger = output . getLogger ( ) ; var end = Date . now ( ) ; var duration = ( end - start ) / 1000 ; logger . info . ok ( 'generation finished with success in ' + duration . toFixed ( 1 ) + 's !' ) ; return output ; } ) ; }
Generate a book using a generator.

The overall process is:
1. List and load plugins for this book
2. Call hook "config"
3. Call hook "init"
4. Initialize generator
5. List all assets and pages
6. Copy all assets to output
7. Generate all pages
8. Call hook "finish:before"
9. Finish generation
10. Call hook "finish"


@param {Generator} generator
@param {Book} book
@param {Object} options
@return {Promise<Output>}
Generate a book using a generator .