-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathgenerate_docs.js
60 lines (56 loc) · 1.46 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
52
53
54
55
56
57
58
59
60
#!/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 partialPaths = require('param-links');
let paths = {
'files#resource':
'https://developers.google.com/drive/v3/reference/files#resource',
'files/list#search-parameters':
'https://developers.google.com/drive/api/v3/search-parameters',
'files/list#request':
'https://developers.google.com/drive/api/v3/reference/files/list#request',
'files/list#response':
'https://developers.google.com/drive/api/v3/reference/files/list#response',
...partialPaths
};
// Build Documentation
documentation
.build(['index.js'], {
shallow: true,
hljs: {
highlightAuto: true,
languages: ['js', 'json']
}
})
.then(res => {
return documentation.formats.md(res, {
paths,
hljs: {
highlightAuto: true,
languages: ['js', 'json']
}
});
})
.then(output => {
output = output.replace(/\n(#+)\s/g, '___\n$1 ');
return fs.writeFileAsync(`${__dirname}/API.md`, output);
})
.catch(function(err) {
console.warn('error when parsing file');
console.error(err);
return;
});