node/tools/eslint/node_modules/shelljs/scripts/generate-docs.js
silverwind d9b8758f47 tools: update ESLint to 2.7.0
PR-URL: https://github.com/nodejs/node/pull/6132
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: thefourtheye <thechargingvolcano@gmail.com>
2016-04-20 16:24:21 -07:00

26 lines
674 B
JavaScript
Executable file

#!/usr/bin/env node
/* globals cat, cd, echo, grep, sed */
require('../global');
echo('Appending docs to README.md');
cd(__dirname + '/..');
// Extract docs from shell.js
var docs = grep('//@', 'shell.js');
docs = docs.replace(/\/\/\@include (.+)/g, function(match, path) {
var file = path.match('.js$') ? path : path+'.js';
return grep('//@', file);
});
// Remove '//@'
docs = docs.replace(/\/\/\@ ?/g, '');
// Wipe out the old docs
cat('README.md').replace(/## Command reference(.|\n)*/, '## Command reference').to('README.md');
// Append new docs to README
sed('-i', /## Command reference/, '## Command reference\n\n' + docs, 'README.md');
echo('All done.');