-
Notifications
You must be signed in to change notification settings - Fork 7
/
assistant.js
53 lines (47 loc) · 1.43 KB
/
assistant.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
/**
* @author Miguel Yax <mig_dj@hotmail.com>
* date 3/31/2017
* generate readme.md based snippet's definition
*/
const { writeFile } = require('fs');
const { displayName, description } = require('./package.json');
const rawSnippets = require('./snippets/apiDocSnippets.json');
const contentList = ['## Content:'];
const exampleList = ['## Example:'];
Object
.keys(rawSnippets)
.sort()
.forEach(name => {
const { description, prefix, body } = rawSnippets[name];
const lowerName = name.toLowerCase().replace(/\s/g, '-');
contentList.push(`- [${description}](#${lowerName})`);
exampleList.push(
`### @${name}`,
`#### \`${prefix} + tab\``,
'```',
...body,
'```');
});
const contributionList = [
'# Contribution',
'* Something is missing?',
'* If you have ideas on how to improve this project let us know.',
'* All contributions are welcome!'
];
const docContent = [
`# ${displayName}`,
`# ${description}`,
'### Basic documetation example:',
'![Image of Snippets](https://raw.githubusercontent.com/Krazeus/ApiDocSnippets/master/images/basic.gif) ',
'### Custom documentation example:',
'![Image of Snippets](https://raw.githubusercontent.com/Krazeus/ApiDocSnippets/master/images/custom.gif) ',
...contentList,
...exampleList,
...contributionList
];
writeFile('README.md', docContent.join('\n'), (err) => {
if (err) {
return console.log(err);
}
console.log('Writed');
});