UNPKG

776 BJavaScriptView Raw
1#!/usr/bin/env node
2/* globals cat, cd, echo, grep, sed, ShellString */
3require('../global');
4
5echo('Appending docs to README.md');
6
7cd(__dirname + '/..');
8
9// Extract docs from shell.js
10var docs = grep('^//@', 'shell.js');
11
12// Now extract docs from the appropriate src/*.js files
13docs = docs.replace(/\/\/\@include (.+)/g, function(match, path) {
14 var file = path.match('.js$') ? path : path+'.js';
15 return grep('^//@', file);
16});
17
18// Remove '//@'
19docs = docs.replace(/\/\/\@ ?/g, '');
20
21// Wipe out the old docs
22ShellString(cat('README.md').replace(/## Command reference(.|\n)*\n## Team/, '## Command reference\n## Team')).to('README.md');
23
24// Append new docs to README
25sed('-i', /## Command reference/, '## Command reference\n\n' + docs, 'README.md');
26
27echo('All done.');