diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/book.js | 20 | ||||
-rw-r--r-- | lib/configuration.js | 4 | ||||
-rw-r--r-- | lib/index.js | 23 |
3 files changed, 39 insertions, 8 deletions
diff --git a/lib/book.js b/lib/book.js index 50ef252..991e126 100644 --- a/lib/book.js +++ b/lib/book.js @@ -22,10 +22,10 @@ var Book = function(root, options) { this.summary = {}; // Glossary - this.glossary = {}; + this.glossary = []; // Langs - this.langs = {}; + this.langs = []; }; // Initialize and parse the book: config, summary, glossary @@ -38,10 +38,10 @@ Book.prototype.init = function() { .then(function() { return that.parseLangs() .then(function() { - multilingal = that.langs.list.length > 0; + multilingal = that.langs.length > 0; // Sub-books that inherit from the current book configuration - that.books = _.map(that.langs.list, function(lang) { + that.books = _.map(that.langs, function(lang) { return new Book( path.join(that.root, lang.path), _.extend({}, that.options, { @@ -63,13 +63,23 @@ Book.prototype.init = function() { .thenResolve(this); }; +// Generate the output +Book.prototype.generate = function() { + var that = this; + + return this.init() + .then(function() { + + }); +}; + // Parse langs Book.prototype.parseLangs = function() { var that = this; return that.findFile("LANGS") .then(function(langs) { - if (!langs) return {}; + if (!langs) return []; return that.readFile(langs.path) .then(function(content) { diff --git a/lib/configuration.js b/lib/configuration.js index 82bf010..2b470c4 100644 --- a/lib/configuration.js +++ b/lib/configuration.js @@ -16,10 +16,10 @@ Configuration.prototype.load = function() { return Q() .then(function() { try { - var _config = require(path.resolve(that.book.root, that.options.)); + var _config = require(path.resolve(that.book.root, that.options.configFile)); that.options = _.merge( that.options, - _.omit(_config, 'input', 'configFile', 'defaultsPlugins', 'generator') + _.omit(_config, 'configFile', 'defaultsPlugins', 'generator', 'extension') ); } catch(err) { diff --git a/lib/index.js b/lib/index.js index a968800..21bc6ff 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,5 +1,26 @@ +var Q = require("q"); +var _ = require("lodash"); +var path = require("path"); +var Book = require("./book"); module.exports = { - Book: require("./book") + Book: Book, + + commands: [ + { + name: "build", + description: "Build a book", + exec: function(args, kwargs) { + var input = args[0] || process.cwd(); + var output = args[1] || path.join(input, "_book"); + + var book = new Book(input, _.extend({}, { + 'output': output + })); + + return book.generate(); + } + } + ] }; |