summaryrefslogtreecommitdiffstats
path: root/lib/book.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-01-19 15:12:08 +0100
committerSamy Pessé <samypesse@gmail.com>2015-01-19 15:12:08 +0100
commit354b4afba1ddd1f86fb587da0c74388df89dbc28 (patch)
tree80c715ee8892af262613d7db033e12b9d69bce57 /lib/book.js
parent8569a741033be6bb3dbfd6fd9ecd3c03f05319c3 (diff)
downloadgitbook-354b4afba1ddd1f86fb587da0c74388df89dbc28.zip
gitbook-354b4afba1ddd1f86fb587da0c74388df89dbc28.tar.gz
gitbook-354b4afba1ddd1f86fb587da0c74388df89dbc28.tar.bz2
Parse readme
Diffstat (limited to 'lib/book.js')
-rw-r--r--lib/book.js30
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;