-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.js
49 lines (39 loc) · 1.02 KB
/
helpers.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
function formatCommentHook(comment) {
let name = comment.tags.find(t => t.tag === 'name').name
let type = comment.tags.find(t => t.tag === 'type').name
let params = comment.tags.filter(t => t.tag === 'param')
let paramsList = params
.map(p => `- ${p.name}(${p.type}): ${p.description}\n`)
.join('')
let changelog = comment.tags
.filter(t => t.tag === 'since')
.sort((a, b) => (a.name < b.name ? 1 : -1)) //Make the like 4.0.1, 3.2.0, 1.0.1
let changelogTableRows = changelog
.map(p => `${p.name} | ${p.description || 'Introduced.'}\n`)
.join('')
let result = `## ${name}(${type})
${comment.description}
### Parameters
${paramsList}
### Source
File: ${comment.file}
### Changelog
Version | Description
------------ | -------------
${changelogTableRows}`
return result
}
function formater(comment, tag) {
var result = ``
switch (tag) {
default:
case 'hook':
result = formatCommentHook(comment)
break
}
return result
}
module.exports = {
formatCommentHook,
formater
}