forked from docstrap/docstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshin-jsdoc-tags.js
More file actions
180 lines (167 loc) · 5.27 KB
/
shin-jsdoc-tags.js
File metadata and controls
180 lines (167 loc) · 5.27 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/**
* @module @shizen/shin-jsdoc-tags
* @desc
* The custom tags used in documenting the `shinstrap` module. If I like these patterns I might export them as a `gist` or
* even elevate them to their own little module which I can include as a dev-dep for other projects.
* @notes
* While I've gone through an retro-fitted `shinstrap` to use ES5 coding styles, as a dev dependency it is not critical for
* for this plugin to follow suit.
* @private
* @addsTag honors Here I could describe the honors tag, I suppose.
* @addsTag tags Etc. Might introduce a specific format for the `@addsTag` jsdoc comment, and then a `listing.scaffolded.tags.tmpl`
*/
// jshint esversion: 6
exports.defineTags = function (dictionary) {
dictionary.defineTag("honors", {
mustHaveValue: false,
canHaveType: true,
canHaveName: true,
onTagged: function (doclet, tag) {
// validate template only?
// console.log("doclet.name", doclet.name);
// console.log("doclet.kind", doclet.kind);
// console.log("tag : %s", Object.getOwnPropertyNames(tag));
// console.log("originalTitle : %s", tag.originalTitle);
// console.log("title : %s", tag.title);
// console.log("text : %s", tag.text);
// console.log("value : %s", Object.getOwnPropertyNames(tag.value));
// console.log("meta : %s", Object.getOwnPropertyNames(doclet.meta));
// console.log("meta : %s", doclet.meta);
if(doclet.honors === undefined) {
doclet.honors = [];
}
// Somehow I thought jsdoc would do this for me given the settings above...
// note that I'm only allowing one type listed here.
// var parsed = tag.text.match(/^([\w.]+)\s+(?:{(\w+)})?\s+(.*)$/);
// if(parsed !== null) {
// doclet.honors.push({
// name: parsed[1],
// type: {
// names: [ parsed[2] ],
// },
// description: parsed[3]
// });
// }
doclet.honors.push({
name: tag.value.name,
type: tag.value.type,
description: tag.value.description,
// optional: tag.value.optional, // They are all more or less optional
defaultvalue: tag.value.defaultvalue
});
// doclet.honors.push(tag.value);
}
});
dictionary.defineTag("tags", {
mustHaveValue: false,
canHaveType: false,
canHaveName: false,
onTagged: function (doclet, tag) {
if(!doclet.tags) {
doclet.tags = [];
}
// Tag handling... Might want to do more rigorous processing and validation
let tags = tag.value.split(",");
for(let idx = tags.length-1; idx >= 0; idx--) {
let t = tags[idx] = tags[idx].trim().toLowerCase();
if(t.length === 0 || tags.indexOf(t) !== idx || doclet.tags.indexOf(t) !== -1) {
tags.splice(idx, 1);
}
}
doclet.tags.push(...tags);
// console.log("Added Tags: %s", tags);
}
});
dictionary.defineTag("redirect", {
mustHaveValue: true,
canHaveType: false,
canHaveName: false,
onTagged: function (doclet, tag) {
doclet.redirect = tag.text;
}
});
dictionary.defineTag("template", {
mustHaveValue: true,
canHaveType: false,
canHaveName: true,
onTagged: function (doclet, tag) {
// console.log("Template %s found (%s)", tag.text, tag.value);
doclet.kind = "template";
// Name specified?
var m = tag.text.match(/^(\w+)\s+(\w+(?:\.(?!tmpl)\w*)*\.tmpl)/);
if(m) {
doclet.name = m[1];
doclet.template = m[2];
} else {
// Match detail.tmpl or detail.blah.tmpl, etc...
var m = tag.text.match(/^(\w+)(?:\.(?!tmpl)\w*)*\.tmpl/);
if(m && m.length > 0) {
doclet.name = m[1];
} else {
doclet.name = tag.text;
}
doclet.template = tag.text;
}
doclet.scope = "static";
}
});
dictionary.defineTag("design", {
mustHaveValue: true,
canHaveType: false,
canHaveName: false,
onTagged: function (doclet, tag) {
doclet.design = tag.value;
}
});
dictionary.defineTag("notes", {
mustHaveValue: true,
canHaveType: false,
canHaveName: false,
onTagged: function (doclet, tag) {
doclet.notes = tag.value;
}
});
dictionary.defineTag("algorithm", {
mustHaveValue: true,
canHaveType: false,
canHaveName: false,
onTagged: function (doclet, tag) {
doclet.algorithm = tag.value;
}
});
dictionary.defineTag("futures", {
mustHaveValue: true,
canHaveType: false,
canHaveName: false,
onTagged: function (doclet, tag) {
if(doclet.futures === undefined) {
doclet.futures = [];
}
doclet.futures.push(tag.value);
}
});
dictionary.defineTag("remarks", {
mustHaveValue: true,
canHaveType: false,
canHaveName: false,
onTagged: function (doclet, tag) {
doclet.remarks = tag.value;
}
});
dictionary.defineTag("changelog", {
mustHaveValue: true,
canHaveType: false,
canHaveName: false,
onTagged: function (doclet, tag) {
doclet.changelog = tag.value;
}
}).synonym('changes');
dictionary.defineTag("issues", {
mustHaveValue: true,
canHaveType: false,
canHaveName: false,
onTagged: function (doclet, tag) {
doclet.issues = tag.value;
}
});
};