forked from motemen/minimatch-cheat-sheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakedoc.js
38 lines (32 loc) · 935 Bytes
/
makedoc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var _ = require('lodash');
var data = require('./data.json');
function codify (str) {
if (str.indexOf('|') === -1) {
return '`' + str + '`';
} else {
return '<code>' + str.replace(/\|/, '|') + '</code>';
}
}
console.log('# minimatch-cheat-sheet');
console.log('');
console.log('A cheat sheet for [minimatch](https://github.com/isaacs/minimatch).');
console.log('');
_.forEach(data, function (entry) {
console.log('## ' + entry.section);
console.log('');
entry.description.forEach(function (desc) {
console.log('- ' + desc);
});
console.log('');
console.log('| Pattern | Matches | Does not match |');
console.log('| ------- | ------- | -------------- |');
entry.examples.forEach(function (ex) {
var row = [
codify(ex[0]),
ex[1].map(codify).join(', '),
ex[2].map(codify).join(', '),
].join(' | ');
console.log('| ' + row + ' |');
});
console.log('');
});