diff options
Diffstat (limited to 'lib/book.js')
-rw-r--r-- | lib/book.js | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/book.js b/lib/book.js index 0f5d452..f920100 100644 --- a/lib/book.js +++ b/lib/book.js @@ -63,6 +63,10 @@ Book.prototype.init = function() { .then(function() { if (multilingal) return; + return that.parseReadme(); + }) + .then(function() { + if (multilingal) return; return that.parseSummary(); }) .then(function() { @@ -82,7 +86,27 @@ Book.prototype.generate = function() { }); }; -// Parse langs +// Parse readme to extract defaults title and description +Book.prototype.parseReadme = function() { + var that = this; + + return that.findFile(that.config.getStructure("readme")) + .then(function(readme) { + if (!readme) throw "No README file"; + + return that.template.renderFile(readme.path) + .then(function(content) { + return readme.parser.readme(content); + }); + }) + .then(function(readme) { + that.options.title = that.options.title || readme.title; + that.options.description = that.options.description || readme.description; + }); +}; + + +// Parse langs to extract list of sub-books Book.prototype.parseLangs = function() { var that = this; @@ -100,7 +124,7 @@ Book.prototype.parseLangs = function() { }); }; -// Parse summary +// Parse summary to extract list of chapters Book.prototype.parseSummary = function() { var that = this; @@ -118,7 +142,7 @@ Book.prototype.parseSummary = function() { }); }; -// Parse glossary +// Parse glossary to extract terms Book.prototype.parseGlossary = function() { var that = this; |