-
Notifications
You must be signed in to change notification settings - Fork 5
/
plugin.ts
78 lines (68 loc) · 2.28 KB
/
plugin.ts
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import ast = require("./lib/ast");
import utils = require("./lib/utils");
var hasOwnProp = Object.prototype.hasOwnProperty;
export function defineTags(dictionary: JSDoc.Dictionary) {
dictionary.defineTag("ctor", {
mustHaveValue: false,
canHaveType: false,
canHaveName: false,
onTagged: (doclet, tag) => {
doclet.addTag("kind", "function");
doclet.addTag("name", "constructor");
doclet.isConstructor = true;
}
});
dictionary.defineTag("callsignature", {
mustHaveValue: false,
canHaveType: false,
canHaveName: false,
onTagged: (doclet, tag) => {
doclet.addTag("kind", "function");
doclet.addTag("name", "call");
doclet.isCallSignature = true;
}
});
dictionary.defineTag("ctorsignature", {
mustHaveValue: false,
canHaveType: false,
canHaveName: false,
onTagged: (doclet, tag) => {
doclet.addTag("kind", "function");
doclet.addTag("name", "new");
doclet.isCtorSignature = true;
}
});
dictionary.defineTag("enum", {
mustHaveValue: true,
canHaveType: true,
canHaveName: true,
onTagged: (doclet: JSDoc.Doclet, tag: JSDoc.ComplexTag) => {
doclet.addTag("kind", "typedef");
doclet.addTag("name", tag.value.name);
// Add the type names and other type properties (such as `optional`).
// Don"t overwrite existing properties.
if (tag.value.type) {
Object.keys(tag.value).forEach(function (prop) {
if (!hasOwnProp.call(doclet, prop)) {
doclet[prop] = tag.value[prop];
}
});
}
doclet.isEnum = true;
}
});
dictionary.defineTag("generic", {
mustHaveValue: true,
canHaveType: false,
onTagged: (doclet, tag) => {
doclet.generic = tag.text;
}
});
};
export var handlers: JSDoc.Plugins.Handlers = {
beforeParse: function (e) {
var opts = ast.getOptionsFromConfig(env.conf.typescript),
comments = ast.getFileComments(e.filename, opts);
e.source = comments.toString();
}
};