summaryrefslogtreecommitdiffstats
path: root/lib/generate/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generate/index.js')
-rw-r--r--lib/generate/index.js36
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 = {