diff options
-rw-r--r-- | lib/book.js | 11 | ||||
-rw-r--r-- | lib/index.js | 5 | ||||
-rw-r--r-- | lib/parser.js | 2 | ||||
-rw-r--r-- | test/helper.js | 4 | ||||
-rw-r--r-- | test/parsing.js | 1 |
5 files changed, 16 insertions, 7 deletions
diff --git a/lib/book.js b/lib/book.js index 6c8fdbb..df19f74 100644 --- a/lib/book.js +++ b/lib/book.js @@ -39,7 +39,7 @@ var Book = function(root, options, parent) { }; // Initialize and parse the book: config, summary, glossary -Book.prototype.init = function() { +Book.prototype.parse = function() { var that = this; var multilingal = false; @@ -81,7 +81,7 @@ Book.prototype.init = function() { // Init sub-books return _.reduce(that.books, function(prev, book) { return prev.then(function() { - return book.init(); + return book.parse(); }); }, Q()); }) @@ -93,7 +93,7 @@ Book.prototype.init = function() { Book.prototype.generate = function() { var that = this; - return this.init() + return Q() .then(function() { }); @@ -219,4 +219,9 @@ Book.prototype.statFile = function(filename) { return fs.stat(path.join(this.root, filename)); }; +// Retrun true if the book is a multilingual book +Book.prototype.isMultilingual = function(filename) { + return this.books.length > 0; +}; + module.exports= Book; diff --git a/lib/index.js b/lib/index.js index 21bc6ff..8b7a390 100644 --- a/lib/index.js +++ b/lib/index.js @@ -19,7 +19,10 @@ module.exports = { 'output': output })); - return book.generate(); + return book.parse() + .then(function() { + return book.generate(); + }); } } ] diff --git a/lib/parser.js b/lib/parser.js index b4243e0..da9732a 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -1,7 +1,7 @@ var _ = require("lodash"); var path = require("path"); -// This list is ordered by priority of parser to use +// This list is ordered by priority of parsers to use var PARSER = [ { extensions: [".md", ".markdown"], diff --git a/test/helper.js b/test/helper.js index f9723b9..74f461a 100644 --- a/test/helper.js +++ b/test/helper.js @@ -17,9 +17,9 @@ before(function(done) { global.book2 = new Book(path.join(__dirname, './fixtures/test2')); qdone( - global.book1.init() + global.book1.parse() .then(function() { - return global.book2.init(); + return global.book2.parse(); }), done ); diff --git a/test/parsing.js b/test/parsing.js index 59ef846..db14d13 100644 --- a/test/parsing.js +++ b/test/parsing.js @@ -31,6 +31,7 @@ describe('Book parsing', function () { it('should correctly parse the languages', function() { assert.equal(book2.books.length, 2); + assert(book2.isMultilingual()); assert.equal(book2.books[0].options.lang, "en"); assert.equal(book2.books[0].options.title, "English Book"); |