forked from vkarpov15/acquit-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocs.js
28 lines (23 loc) · 873 Bytes
/
docs.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
var acquit = require('acquit');
var content = require('fs').readFileSync('test/api-integration.test.js').toString();
var blocks = acquit.parse(content);
var header = require('fs').readFileSync('./header.md').toString();
var mdOutput = header + '\n\n';
for (var i = 0; i < blocks.length; ++i) {
var describe = blocks[i];
mdOutput += '## ' + describe.contents + '\n\n';
mdOutput += describe.comments[0] ?
acquit.trimEachLine(describe.comments[0]) + '\n\n' :
'';
for (var j = 0; j < describe.blocks.length; ++j) {
var it = describe.blocks[j];
mdOutput += '#### It ' + it.contents + '\n\n';
mdOutput += it.comments[0] ?
acquit.trimEachLine(it.comments[0]) + '\n\n' :
'';
mdOutput += '```javascript\n';
mdOutput += ' ' + it.code + '\n';
mdOutput += '```\n\n';
}
}
require('fs').writeFileSync('README.md', mdOutput);