-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_docs.js
51 lines (47 loc) · 1.31 KB
/
generate_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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
/**
* Script to generate the documentation based in JSDoc Annotations
*
* @example ./tasks/generate_docs.js
*
* @name {generate_docs}
*/
const path = require('path'),
documentation = require('documentation'),
Promise = require('bluebird'),
fs = Promise.promisifyAll(require("fs"));
/**
* Cotains type definitions and where should their link point to
*
* @type {Object}
*/
const paths = {
Promise: 'http://bluebirdjs.com/docs/api-reference.html',
HTML2Canvas: "https://html2canvas.hertzen.com/",
Canvg: "https://github.com/canvg/canvg",
jQuery: "https://api.jquery.com/jQuery/",
Cash: "https://github.com/kenwheeler/cash"
};
// Build Documentation
documentation.build(['src/ig_screenshot.js'], {
shallow: true,
hljs: {
highlightAuto: true,
languages: ['js', 'json', 'sql', 'sh', 'bash']
}
}).then(res => {
return documentation.formats.md(res, {
paths,
hljs: {
highlightAuto: true,
languages: ['js', 'json', 'sql', 'sh', 'bash']
}
});
}).then(output => {
output = output.replace(/\n(#+)\s/g, "___\n$1 ");
return fs.writeFileAsync(`${__dirname}/USAGE.md`, output);
}).catch(function (err) {
console.warn('error when parsing file');
console.error(err);
return;
});