UNPKG

mecano

Version:

Common functions for system deployment.

55 lines (47 loc) 1.62 kB
// Generated by CoffeeScript 1.7.1 var date, destination, docs, fs, mecano, source; fs = require('fs'); mecano = require('..'); date = function() { var d; return d = (new Date).toISOString(); }; source = "" + __dirname + "/mecano.coffee"; destination = "" + __dirname + "/../doc/index.md"; docs = "---\nlanguage: en\nlayout: page\ntitle: \"Node Mecano: Common functions for system deployment\"\ndate: " + (date()) + "\ncomments: false\nsharing: false\nfooter: false\ngithub: https://github.com/wdavidw/node-mecano\n---"; fs.readFile(source, 'ascii', function(err, content) { var match, re, re_code; re = /###\n([\s\S]*?)\n( *)###/g; re_code = /\n(\s{4}\s*?\w[\s\S]*?)\n(?!\s)/g; match = re.exec(content); docs += match[1]; while (match = re.exec(content)) { match[1] = match[1].split('\n').map(function(line) { return line.substr(2); }).join('\n'); match[1] = match[1].replace(re_code, function(str, code) { code = code.split('\n').map(function(line) { return line.substr(4); }).join('\n'); return "\n```coffeescript\n" + code + "\n```"; }); docs += match[1]; } return fs.writeFile(destination, docs, function(err) { if (err) { return console.log(err.message); } console.log('Documentation generated'); destination = process.argv[2]; if (!destination) { return; } return mecano.copy({ source: "" + __dirname + "/../doc/index.md", destination: destination, force: true }, function(err, copied) { return console.log("Documentation published: " + destination); }); }); });