Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
docSet.dsidx
reference.html
node_modules/
56 changes: 28 additions & 28 deletions generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -120,7 +107,6 @@ var createSearchIndex = function (markdown) {
});
};


var generateHtml = function (markdown) {
var payload = {
text: markdown,
Expand Down Expand Up @@ -169,7 +155,7 @@ var addDashAnchors = function (text) {
return resolve(text);
});
});
}
};

var wrapInDocument = function (text) {
return Q.Promise(function (resolve) {
Expand All @@ -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);
});
});
});
});
Binary file added releases/hapi-13.4.x.tgz
Binary file not shown.