Skip to content
Browse files

docs; fix version

  • Loading branch information...
1 parent 11f10ca commit 8a39a6676af100fa0b1d6f6b532f0eefeccfb622 @aheckmann aheckmann committed
Showing with 62 additions and 2 deletions.
  1. +48 −0 docs/website.js
  2. +14 −2 website.js
View
48 docs/website.js
@@ -0,0 +1,48 @@
+
+var fs= require('fs')
+var jade = require('jade')
+var package = require('./package')
+var hl = require('./docs/helpers/highlight')
+var linktype = require('./docs/helpers/linktype')
+var href = require('./docs/helpers/href')
+var klass = require('./docs/helpers/klass')
+
+// add custom jade filters
+require('./docs/helpers/filters')(jade);
+
+// clean up version for ui
+package.version = package.version.replace(/-pre$/, '');
+
+var filemap = require('./docs/source');
+var files = Object.keys(filemap);
+
+files.forEach(function (file) {
+ var filename = __dirname + '/' + file;
+ jadeify(filename, filemap[file]);
+
+ if ('--watch' == process.argv[2]) {
+ fs.watchFile(filename, { interval: 1000 }, function (cur, prev) {
+ if (cur.mtime > prev.mtime) {
+ jadeify(filename, filemap[file]);
+ }
+ });
+ }
+});
+
+function jadeify (filename, options) {
+ options || (options = {});
+ options.package = package;
+ options.hl = hl;
+ options.linktype = linktype;
+ options.href = href;
+ options.klass = klass;
+ jade.renderFile(filename, options, function (err, str) {
+ if (err) return console.error(err.stack);
+
+ var newfile = filename.replace('.jade', '.html')
+ fs.writeFile(newfile, str, function (err) {
+ if (err) return console.error('could not write', err.stack);
+ console.log('%s : rendered ', new Date, newfile);
+ });
+ });
+}
View
16 website.js
@@ -10,8 +10,8 @@ var klass = require('./docs/helpers/klass')
// add custom jade filters
require('./docs/helpers/filters')(jade);
-// clean up version for ui
-package.version = package.version.replace(/-pre$/, '');
+// use last release
+package.version = getVersion();
var filemap = require('./docs/source');
var files = Object.keys(filemap);
@@ -46,3 +46,15 @@ function jadeify (filename, options) {
});
});
}
+
+function getVersion () {
+ var hist = fs.readFileSync('./History.md','utf8').replace(/\r/g, '\n').split('\n');
+ for (var i = 0; i < hist.length; ++i) {
+ var line = (hist[i] || '').trim();
+ if (!line) continue;
+ var match = /^\s*([^\s]+)\s/.exec(line);
+ if (match && match[1])
+ return match[1];
+ }
+ throw new Error('no match found');
+}

0 comments on commit 8a39a66

Please sign in to comment.
Something went wrong with that request. Please try again.