mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Parse readme
This commit is contained in:
+27
-3
@@ -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;
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ Configuration.DEFAULT = {
|
||||
|
||||
// Structure
|
||||
"structure": {
|
||||
"langs": "README.md",
|
||||
"readme": "README.md",
|
||||
"glossary": "GLOSSARY.md",
|
||||
"summary": "SUMMARY.md"
|
||||
|
||||
Reference in New Issue
Block a user