@@ -126,17 +126,45 @@ const hasDefinedTypeReturnTag = (tag) => {
126
126
return true ;
127
127
} ;
128
128
129
+ const tagsWithOptionalType = [
130
+ 'augments' , 'extends' ,
131
+ 'class' , 'constructor' ,
132
+ 'constant' , 'const' ,
133
+ 'enum' ,
134
+ 'implements' ,
135
+ 'member' , 'var' ,
136
+ 'module' ,
137
+ 'namespace' ,
138
+ 'param' , 'arg' , 'argument' ,
139
+ 'property' , 'prop' ,
140
+ 'returns' , 'return' ,
141
+ 'throws' , 'exception' ,
142
+ 'type' ,
143
+ 'typedef' ,
144
+ 'yields' , 'yield' ,
145
+
146
+ // GCC specific
147
+ 'package' ,
148
+ 'private' ,
149
+ 'protected' ,
150
+ 'public' ,
151
+ 'static' ,
152
+ ] ;
153
+
154
+ const tagsWithMandatoryType = [
155
+ 'enum' ,
156
+ 'implements' ,
157
+ 'member' , 'var' ,
158
+ 'module' ,
159
+ 'type' ,
160
+ 'typedef' ,
161
+ ] ;
162
+
129
163
const namepathDefiningTags = [
130
- // NOT USEFUL WITHOUT NAMEPATH
131
164
'external' , 'host' ,
132
165
'name' ,
133
166
'typedef' ,
134
-
135
- // MAY BE USEFUL WITHOUT NAMEPATH
136
167
'event' ,
137
-
138
- // MAY BE USEFUL WITHOUT NAMEPATH (OR
139
- // BLOCK CAN USE NAMEPATH FROM ELSEWHERE)
140
168
'class' , 'constructor' ,
141
169
'constant' , 'const' ,
142
170
'callback' ,
@@ -147,126 +175,68 @@ const namepathDefiningTags = [
147
175
'namespace' ,
148
176
] ;
149
177
150
- const namepathPointingTags = [
151
- // NOT USEFUL WITHOUT NAMEPATH
178
+ const tagsWithOptionalNamepath = [
179
+ ... namepathDefiningTags ,
152
180
'alias' ,
153
181
'augments' , 'extends' ,
154
182
155
183
// `borrows` has a different format, however, so needs special parsing
156
184
'borrows' ,
185
+ 'emits' , 'fires' ,
157
186
'lends' ,
158
- 'memberof ' ,
159
- 'memberof!' ,
187
+ 'listens ' ,
188
+ 'memberof' , 'memberof !',
160
189
'mixes' ,
190
+ 'see' ,
161
191
'this' ,
162
-
163
- // MAY BE USEFUL WITHOUT NAMEPATH
164
- 'emits' ,
165
- 'fires' ,
166
- 'listens' ,
167
192
] ;
168
193
169
- const isNamepathDefiningTag = ( tagName ) => {
170
- return namepathDefiningTags . includes ( tagName ) ;
171
- } ;
172
-
173
- const isNamepathPointingTag = ( tagName , checkSeesForNamepaths ) => {
174
- return namepathPointingTags . includes ( tagName ) ||
175
- tagName === 'see' && checkSeesForNamepaths ;
176
- } ;
177
-
178
- const isNamepathTag = ( tagName , checkSeesForNamepaths ) => {
179
- return isNamepathDefiningTag ( tagName ) ||
180
- isNamepathPointingTag ( tagName , checkSeesForNamepaths ) ;
181
- } ;
182
-
183
- const potentiallyEmptyNamepathTags = [
184
- // These may serve some minor purpose when empty or
185
- // their namepath can be expressed elsewhere on the block
186
- 'event' ,
194
+ const tagsWithMandatoryNamepath = [
187
195
'callback' ,
188
- 'class' , 'constructor' ,
189
- 'extends' , 'augments' ,
190
- 'constant' , 'const' ,
191
- 'function' , 'func' , 'method' ,
192
- 'interface' ,
193
- 'member' , 'var' ,
194
- 'mixin' ,
195
- 'namespace' ,
196
- 'listens' , 'fires' , 'emits' ,
197
- 'see' ,
198
-
199
- // GCC syntax allows typedef to be named through variable declaration rather than jsdoc name
196
+ 'external' , 'host' ,
197
+ 'name' ,
200
198
'typedef' ,
201
199
] ;
202
200
203
- const isPotentiallyEmptyNamepathTag = ( tag ) => {
204
- return potentiallyEmptyNamepathTags . includes ( tag ) ;
205
- } ;
206
-
207
- let tagsWithTypes = [
201
+ const tagsWithMandatoryEitherTypeOrNamepath = [
202
+ 'alias' ,
208
203
'augments' , 'extends' ,
209
- 'class' ,
210
- 'constant' ,
211
- 'enum' ,
212
- 'implements' ,
213
- 'member' ,
214
- 'module' ,
215
- 'namespace' ,
216
- 'param' ,
217
- 'property' ,
218
- 'returns' ,
219
- 'throws' ,
220
- 'type' ,
204
+ 'borrows' ,
205
+ 'external' , 'host' ,
206
+ 'lends' ,
207
+ 'memberof' , 'memberof!' ,
208
+ 'mixes' ,
209
+ 'name' ,
210
+ 'this' ,
221
211
'typedef' ,
222
- 'yields' ,
223
212
] ;
224
213
225
- const closureTagsWithTypes = [
226
- 'package' , 'private' , 'protected' , 'public' , 'static' ,
227
- ] ;
214
+ const isNamepathDefiningTag = ( tagName ) => {
215
+ return namepathDefiningTags . includes ( tagName ) ;
216
+ } ;
228
217
229
- const tagsWithTypesAliases = [
230
- 'constructor' ,
231
- 'const' ,
232
- 'var' ,
233
- 'arg' ,
234
- 'argument' ,
235
- 'prop' ,
236
- 'return' ,
237
- 'exception' ,
238
- 'yield' ,
239
- ] ;
218
+ const tagMightHaveType = ( tag ) => {
219
+ return tagsWithOptionalType . includes ( tag ) ;
220
+ } ;
240
221
241
- tagsWithTypes = tagsWithTypes . concat ( tagsWithTypesAliases , closureTagsWithTypes ) ;
222
+ const tagMustHaveType = ( tag ) => {
223
+ return tagsWithMandatoryType . includes ( tag ) ;
224
+ } ;
242
225
243
- const potentiallyEmptyTypeTags = [
244
- 'class' , 'constructor' ,
245
- 'constant' , 'const' ,
246
- 'extends' , 'augments' ,
247
- 'namespace' ,
248
- 'param' , 'arg' ,
249
- 'return' , 'returns' ,
250
- 'throws' , 'exception' ,
251
- 'yields' , 'yield' ,
252
- 'package' , 'private' , 'protected' , 'public' , 'static' ,
253
- ] ;
226
+ const tagMightHaveNamepath = ( tag ) => {
227
+ return tagsWithOptionalNamepath . includes ( tag ) ;
228
+ } ;
254
229
255
- const isPotentiallyEmptyTypeTag = ( tag ) => {
256
- return potentiallyEmptyTypeTags . includes ( tag ) ;
230
+ const tagMustHaveNamepath = ( tag ) => {
231
+ return tagsWithMandatoryNamepath . includes ( tag ) ;
257
232
} ;
258
233
259
- const isTagWithType = ( tagName ) => {
260
- return tagsWithTypes . includes ( tagName ) ;
234
+ const tagMightHaveEitherTypeOrNamepath = ( tag ) => {
235
+ return tagMightHaveType ( tag ) || tagMightHaveNamepath ( tag ) ;
261
236
} ;
262
237
263
- const tagsWithMandatoryNamepathOrType = [
264
- 'augments' , 'extends' ,
265
- 'param' , 'arg' ,
266
- 'typedef' ,
267
- ] ;
268
- const isTagWithMandatoryNamepathOrType = ( tagName ) => {
269
- return tagsWithMandatoryNamepathOrType . includes ( tagName ) ;
238
+ const tagMustHaveEitherTypeOrNamepath = ( tag ) => {
239
+ return tagsWithMandatoryEitherTypeOrNamepath . includes ( tag ) ;
270
240
} ;
271
241
272
242
/**
@@ -451,11 +421,12 @@ export default {
451
421
hasReturnValue,
452
422
hasTag,
453
423
isNamepathDefiningTag,
454
- isNamepathTag,
455
- isPotentiallyEmptyNamepathTag,
456
- isPotentiallyEmptyTypeTag,
457
- isTagWithMandatoryNamepathOrType,
458
- isTagWithType,
459
424
isValidTag,
460
425
parseClosureTemplateTag,
426
+ tagMightHaveEitherTypeOrNamepath,
427
+ tagMightHaveNamepath,
428
+ tagMightHaveType,
429
+ tagMustHaveEitherTypeOrNamepath,
430
+ tagMustHaveNamepath,
431
+ tagMustHaveType,
461
432
} ;
0 commit comments