diff --git a/.gitignore b/.gitignore index 387ff62..d80c229 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ docSet.dsidx reference.html +node_modules/ \ No newline at end of file diff --git a/generate.js b/generate.js index 5a0359e..c718cbe 100644 --- a/generate.js +++ b/generate.js @@ -9,24 +9,11 @@ var referenceUrl = 'https://raw.githubusercontent.com/hapijs/hapi/master/API.md' var Path = require('path'); var documentsPath = Path.join(__dirname, './' + docsetName + '/Contents/Resources/Documents/'); -mkdirp(documentsPath, function (err) {}); - var dbFile = Path.join(__dirname, './' + docsetName + '/Contents/Resources/docSet.dsidx'); -fs.unlink(dbFile, function(error) { - if (!error) { - console.log('Previous database deleted!'); - }; -}); - -var db = new sqlite3.Database(dbFile); -db.serialize(function () { - db.run("CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);"); - db.run("CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);"); -}); +var db; var hapiVersion = "NO-VERSION"; - var prepareIndexEntry = function (method, anchor) { var type = 'Guide'; @@ -120,7 +107,6 @@ var createSearchIndex = function (markdown) { }); }; - var generateHtml = function (markdown) { var payload = { text: markdown, @@ -169,7 +155,7 @@ var addDashAnchors = function (text) { return resolve(text); }); }); -} +}; var wrapInDocument = function (text) { return Q.Promise(function (resolve) { @@ -193,16 +179,30 @@ var writeFile = function (text) { }); }; -fetchRawMarkdown(referenceUrl) - .then(echoVersion) - .then(createSearchIndex) - .then(generateHtml) - .then(replaceUserContent) - .then(addDashAnchors) - .then(wrapInDocument) - .then(writeFile) - .then(function (markdown) { - console.log('Generation of hapi.docset version '+hapiVersion+' completed!'); - }).catch(function (e) { - console.log(e); +mkdirp(documentsPath, function (err) { + fs.unlink(dbFile, function(error) { + if (!error) { + console.log('Previous database deleted!'); + } + + db = new sqlite3.Database(dbFile); + db.serialize(function () { + db.run("CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);"); + db.run("CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);"); + + fetchRawMarkdown(referenceUrl) + .then(echoVersion) + .then(createSearchIndex) + .then(generateHtml) + .then(replaceUserContent) + .then(addDashAnchors) + .then(wrapInDocument) + .then(writeFile) + .then(function (markdown) { + console.log('Generation of hapi.docset version '+hapiVersion+' completed!'); + }).catch(function (e) { + console.log(e); + }); + }); }); +}); diff --git a/releases/hapi-13.4.x.tgz b/releases/hapi-13.4.x.tgz new file mode 100644 index 0000000..04d8820 Binary files /dev/null and b/releases/hapi-13.4.x.tgz differ