diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-06 12:52:35 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-06 12:52:35 -0700 |
commit | 53f714b7f3ac2523a4ce98dcb1a1b8a8ee687c43 (patch) | |
tree | a0af3069daec9c7e5b7c2944aee8a107c40a1847 /lib/generate/index.js | |
parent | d19906d5b2638cd55c1b65eeab3327d7533ebca1 (diff) | |
download | gitbook-53f714b7f3ac2523a4ce98dcb1a1b8a8ee687c43.zip gitbook-53f714b7f3ac2523a4ce98dcb1a1b8a8ee687c43.tar.gz gitbook-53f714b7f3ac2523a4ce98dcb1a1b8a8ee687c43.tar.bz2 |
Add base for generating languages index
Diffstat (limited to 'lib/generate/index.js')
-rw-r--r-- | lib/generate/index.js | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js index b46c96b..c8b98ef 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -61,6 +61,11 @@ var generate = function(options) { }) }) + // Create the generator + .then(function() { + generator = new generators[options.generator](options); + }) + // Detect multi-languages book .then(function() { if (_.contains(files, "README.md") && _.contains(files, "LANGS.md")) { @@ -69,22 +74,22 @@ var generate = function(options) { // Generate sub-books .then(function(_langsSummary) { - options.langsSummary = parse.summary(_langsSummary); + options.langsSummary = parse.langs(_langsSummary); // Generated a book for each valid entry return Q.all( - _.chain(langsSummary.chapters) - .filter(function(entry) { - return entry.path != null; - }) - .map(function(entry) { + _.map(options.langsSummary.list, function(entry) { return generate(_.extend({}, options, { input: path.join(options.input, entry.path), output: path.join(options.output, entry.path) })); - }) - .value() + }) ); + }) + + // Generate languages index + .then(function() { + return generator.langsIndex(options.langsSummary); }); } else if (!_.contains(files, "SUMMARY.md") || !_.contains(files, "README.md")) { // Invalid book @@ -101,11 +106,6 @@ var generate = function(options) { options.navigation = parse.navigation(options.summary); }) - // Create the generator - .then(function() { - generator = new generators[options.generator](options); - }) - // Copy file and replace markdown file .then(function() { return Q.all( @@ -127,13 +127,13 @@ var generate = function(options) { .value() ); }) - - // Finish gneration - .then(function() { - return generator.finish(); - }); } }) + + // Finish gneration + .then(function() { + return generator.finish(); + }); }; module.exports = { |