summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/book.js13
-rw-r--r--lib/configuration.js8
-rw-r--r--test/fixtures/test2/LANGS.md4
-rw-r--r--test/fixtures/test2/README.md2
-rw-r--r--test/fixtures/test2/en/README.md1
-rw-r--r--test/fixtures/test2/en/SUMMARY.md1
-rw-r--r--test/fixtures/test2/fr/README.md1
-rw-r--r--test/fixtures/test2/fr/SUMMARY.md1
-rw-r--r--test/helper.js9
-rw-r--r--test/parsing.js4
10 files changed, 41 insertions, 3 deletions
diff --git a/lib/book.js b/lib/book.js
index 5335896..6c8fdbb 100644
--- a/lib/book.js
+++ b/lib/book.js
@@ -33,6 +33,9 @@ var Book = function(root, options, parent) {
// Langs
this.langs = [];
+
+ // Sub-books
+ this.books = [];
};
// Initialize and parse the book: config, summary, glossary
@@ -73,6 +76,16 @@ Book.prototype.init = function() {
if (multilingal) return;
return that.parseGlossary();
})
+
+ .then(function() {
+ // Init sub-books
+ return _.reduce(that.books, function(prev, book) {
+ return prev.then(function() {
+ return book.init();
+ });
+ }, Q());
+ })
+
.thenResolve(this);
};
diff --git a/lib/configuration.js b/lib/configuration.js
index 0b3073f..daf1b3c 100644
--- a/lib/configuration.js
+++ b/lib/configuration.js
@@ -6,7 +6,8 @@ var fs = require("./utils/fs");
var Configuration = function(book, options) {
this.book = book;
- this.options = _.extend({}, Configuration.DEFAULT, options || {});
+ this.options = _.cloneDeep(Configuration.DEFAULT);
+ this.options = _.merge(this.options, options || {});
};
// Read and parse the configuration
@@ -25,6 +26,9 @@ Configuration.prototype.load = function() {
catch(err) {
return Q();
}
+ })
+ .then(function() {
+ that.options.output = that.options.output || path.join(that.book.root, "_book");
});
};
@@ -48,7 +52,7 @@ Configuration.DEFAULT = {
// Structure
"structure": {
- "langs": "README.md",
+ "langs": "LANGS.md",
"readme": "README.md",
"glossary": "GLOSSARY.md",
"summary": "SUMMARY.md"
diff --git a/test/fixtures/test2/LANGS.md b/test/fixtures/test2/LANGS.md
new file mode 100644
index 0000000..a501d22
--- /dev/null
+++ b/test/fixtures/test2/LANGS.md
@@ -0,0 +1,4 @@
+# Languages
+
+* [English](en/)
+* [French](fr/)
diff --git a/test/fixtures/test2/README.md b/test/fixtures/test2/README.md
new file mode 100644
index 0000000..c6186ac
--- /dev/null
+++ b/test/fixtures/test2/README.md
@@ -0,0 +1,2 @@
+# Multi-Languages test
+
diff --git a/test/fixtures/test2/en/README.md b/test/fixtures/test2/en/README.md
new file mode 100644
index 0000000..95bc71c
--- /dev/null
+++ b/test/fixtures/test2/en/README.md
@@ -0,0 +1 @@
+# English Book
diff --git a/test/fixtures/test2/en/SUMMARY.md b/test/fixtures/test2/en/SUMMARY.md
new file mode 100644
index 0000000..ac9323c
--- /dev/null
+++ b/test/fixtures/test2/en/SUMMARY.md
@@ -0,0 +1 @@
+# Summary
diff --git a/test/fixtures/test2/fr/README.md b/test/fixtures/test2/fr/README.md
new file mode 100644
index 0000000..c7a4103
--- /dev/null
+++ b/test/fixtures/test2/fr/README.md
@@ -0,0 +1 @@
+# French Book
diff --git a/test/fixtures/test2/fr/SUMMARY.md b/test/fixtures/test2/fr/SUMMARY.md
new file mode 100644
index 0000000..ac9323c
--- /dev/null
+++ b/test/fixtures/test2/fr/SUMMARY.md
@@ -0,0 +1 @@
+# Summary
diff --git a/test/helper.js b/test/helper.js
index f80edcb..f9723b9 100644
--- a/test/helper.js
+++ b/test/helper.js
@@ -14,6 +14,13 @@ global.qdone = function qdone(promise, done) {
// Init before doing tests
before(function(done) {
global.book1 = new Book(path.join(__dirname, './fixtures/test1'));
+ global.book2 = new Book(path.join(__dirname, './fixtures/test2'));
- qdone(global.book1.init(), done);
+ qdone(
+ global.book1.init()
+ .then(function() {
+ return global.book2.init();
+ }),
+ done
+ );
});
diff --git a/test/parsing.js b/test/parsing.js
index 1464ed2..b1c4114 100644
--- a/test/parsing.js
+++ b/test/parsing.js
@@ -28,4 +28,8 @@ describe('Book parsing', function () {
assert.equal(LEXED[1].name, "Test 2");
assert.equal(LEXED[1].description, "a second test");
});
+
+ it('should correctly parse the languages', function() {
+ assert.equal(book2.books.length, 2);
+ });
});