diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-19 09:47:36 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-19 09:47:36 +0100 |
commit | ec586dd3cdf06e9567f5d3e4961022ddc3c94778 (patch) | |
tree | cc7825ab73110b4e6fbedee404427b052edffa17 /lib/generate/json/index.js | |
parent | 80432161708357bdcf0e00533d9e6d327636dab6 (diff) | |
download | gitbook-ec586dd3cdf06e9567f5d3e4961022ddc3c94778.zip gitbook-ec586dd3cdf06e9567f5d3e4961022ddc3c94778.tar.gz gitbook-ec586dd3cdf06e9567f5d3e4961022ddc3c94778.tar.bz2 |
Clear folder
Diffstat (limited to 'lib/generate/json/index.js')
-rw-r--r-- | lib/generate/json/index.js | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/lib/generate/json/index.js b/lib/generate/json/index.js deleted file mode 100644 index a252ed3..0000000 --- a/lib/generate/json/index.js +++ /dev/null @@ -1,77 +0,0 @@ -var util = require("util"); -var path = require("path"); -var Q = require("q"); -var _ = require("lodash"); - -var fs = require("../fs"); -var parse = require("../../parse"); -var BaseGenerator = require("../generator"); - - -var Generator = function() { - BaseGenerator.apply(this, arguments); -}; -util.inherits(Generator, BaseGenerator); - -Generator.prototype.transferFile = function(input) { - // ignore -}; - -Generator.prototype.convertFile = function(content, input) { - var that = this; - var json = { - progress: parse.progress(this.options.navigation, input) - }; - - return Q() - .then(function() { - return parse.page(content, { - dir: path.dirname(input) || '/' - }); - }) - .then(function(parsed) { - json.lexed = parsed.lexed; - json.sections = parsed.sections; - }) - .then(function() { - return fs.writeFile( - path.join(that.options.output, input.replace(".md", ".json")), - JSON.stringify(json, null, 4) - ); - }); -}; - -// Generate languages index -// Contains the first languages readme and langs infos -Generator.prototype.langsIndex = function(langs) { - var that = this; - - if (langs.list.length == 0) return Q.reject("Need at least one language"); - - var mainLang = _.first(langs.list).lang; - console.log("Main language is", mainLang); - - return Q() - .then(function() { - return fs.readFile( - path.join(that.options.output, mainLang, "README.json") - ); - }) - .then(function(content) { - var json = JSON.parse(content); - _.extend(json, { - langs: langs.list - }); - - return fs.writeFile( - path.join(that.options.output, "README.json"), - JSON.stringify(json, null, 4) - ); - }); -}; - -Generator.prototype.finish = function() { - // ignore -}; - -module.exports = Generator; |