-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
states.js
38 lines (31 loc) · 978 Bytes
/
states.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
export default function statesPlugin() {
return (comment) => {
const cmt = {};
const tags = comment.tags
.map((tag) => {
if (/returns?/.test(tag.title)) {
const desc = tag.description || '';
if (tag.type.expression && !tag.type.applications) {
tag.type.name = tag.type.expression.name;
} else if (tag.type.expression && tag.type.applications) {
tag.type.name = `${tag.type.expression.name}<${
tag.type.applications[0].name
}>`;
}
cmt.return = { description: desc, type: tag.type };
return null;
}
if (['public', 'private', 'protected'].includes(tag.title)) {
cmt[tag.title] = true;
return null;
}
if (tag.title === 'api') {
cmt[tag.description] = true;
return null;
}
return tag;
})
.filter(Boolean);
return { ...cmt, tags };
};
}