Parse readme

This commit is contained in:
Samy Pessé
2015-01-19 15:12:08 +01:00
parent 8569a74103
commit 354b4afba1
2 changed files with 28 additions and 3 deletions
+27 -3
View File
@@ -61,6 +61,10 @@ Book.prototype.init = function() {
});
})
.then(function() {
if (multilingal) return;
return that.parseReadme();
})
.then(function() {
if (multilingal) return;
return that.parseSummary();
@@ -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;
+1
View File
@@ -48,6 +48,7 @@ Configuration.DEFAULT = {
// Structure
"structure": {
"langs": "README.md",
"readme": "README.md",
"glossary": "GLOSSARY.md",
"summary": "SUMMARY.md"