@@ -4,6 +4,17 @@ import javascript
44
55/**
66 * A JSDoc comment.
7+ *
8+ * Example:
9+ *
10+ * <pre>
11+ * /**
12+ * * An example JSDoc comment documenting a constructor function.
13+ * *
14+ * * @constructor
15+ * * @param {Object=} options An object literal with options.
16+ * */
17+ * </pre>
718 */
819class JSDoc extends @jsdoc, Locatable {
920 override Location getLocation ( ) { hasLocation ( this , result ) }
@@ -28,6 +39,20 @@ class JSDoc extends @jsdoc, Locatable {
2839
2940/**
3041 * A program element that can have a JSDoc comment.
42+ *
43+ * Example:
44+ *
45+ * <pre>
46+ * /**
47+ * * An example JSDoc comment documenting a constructor function.
48+ * *
49+ * * @constructor
50+ * * @param {Object=} options An object literal with options.
51+ * */
52+ * function MyConstructor(options) { // documentable
53+ * this.options = options || {};
54+ * }
55+ * </pre>
3156 */
3257abstract class Documentable extends ASTNode {
3358 /** Gets the JSDoc comment for this element, if any. */
@@ -38,6 +63,13 @@ abstract class Documentable extends ASTNode {
3863/**
3964 * A syntactic element that a JSDoc type expression may be nested in, that is,
4065 * either a JSDoc tag or another JSDoc type expression.
66+ *
67+ * Examples:
68+ *
69+ * ```
70+ * // the `@param` tag and the `...=` type expressions are JSDoc type expression parents
71+ * @param {Object=} options An object literal with options.
72+ * ```
4173 */
4274class JSDocTypeExprParent extends @jsdoc_type_expr_parent, Locatable {
4375 override Location getLocation ( ) { hasLocation ( this , result ) }
@@ -46,7 +78,14 @@ class JSDocTypeExprParent extends @jsdoc_type_expr_parent, Locatable {
4678}
4779
4880/**
49- * A JSDoc tag such as `@param Object options An object literal with options.`
81+ * A JSDoc tag.
82+ *
83+ * Examples:
84+ *
85+ * ```
86+ * @param {Object=} options An object literal with options.
87+ * @return {!Server}
88+ * ```
5089 */
5190class JSDocTag extends @jsdoc_tag, JSDocTypeExprParent {
5291 /** Gets the tag title; for instance, the title of a `@param` tag is `"param"`. */
@@ -90,6 +129,12 @@ class JSDocTag extends @jsdoc_tag, JSDocTypeExprParent {
90129
91130/**
92131 * A `@param` tag.
132+ *
133+ * Example:
134+ *
135+ * ```
136+ * @param {Object=} options An object literal with options.
137+ * ```
93138 */
94139class JSDocParamTag extends JSDocTag {
95140 JSDocParamTag ( ) { getTitle ( ) .regexpMatch ( "param|arg(ument)?" ) }
@@ -104,6 +149,14 @@ class JSDocParamTag extends JSDocTag {
104149
105150/**
106151 * A JSDoc type expression.
152+ *
153+ * Examples:
154+ *
155+ * ```
156+ * *
157+ * Array<string>
158+ * !Object
159+ * ```
107160 */
108161class JSDocTypeExpr extends @jsdoc_type_expr, JSDocTypeExprParent , TypeAnnotation {
109162 /**
@@ -148,32 +201,81 @@ class JSDocTypeExpr extends @jsdoc_type_expr, JSDocTypeExprParent, TypeAnnotatio
148201 override TopLevel getTopLevel ( ) { result = getEnclosingStmt ( ) .getTopLevel ( ) }
149202}
150203
151- /** An `any` type expression `*`. */
204+ /**
205+ * An `any` type expression.
206+ *
207+ * Example:
208+ *
209+ * ```
210+ * *
211+ * ```
212+ */
152213class JSDocAnyTypeExpr extends @jsdoc_any_type_expr, JSDocTypeExpr {
153214 override predicate isAny ( ) { any ( ) }
154215}
155216
156- /** A null type expression. */
217+ /**
218+ * A null type expression.
219+ *
220+ * Example:
221+ *
222+ * ```
223+ * null
224+ * ```
225+ */
157226class JSDocNullTypeExpr extends @jsdoc_null_type_expr, JSDocTypeExpr {
158227 override predicate isNull ( ) { any ( ) }
159228}
160229
161- /** A type expression representing the type of `undefined`. */
230+ /**
231+ * A type expression representing the type of `undefined`.
232+ *
233+ * Example:
234+ *
235+ * ```
236+ * undefined
237+ * ```
238+ */
162239class JSDocUndefinedTypeExpr extends @jsdoc_undefined_type_expr, JSDocTypeExpr {
163240 override predicate isUndefined ( ) { any ( ) }
164241}
165242
166- /** A type expression representing an unknown type `?`. */
243+ /**
244+ * A type expression representing an unknown type.
245+ *
246+ * Example:
247+ *
248+ * ```
249+ * ?
250+ * ```
251+ */
167252class JSDocUnknownTypeExpr extends @jsdoc_unknown_type_expr, JSDocTypeExpr {
168253 override predicate isUnknownKeyword ( ) { any ( ) }
169254}
170255
171- /** A type expression representing the void type. */
256+ /**
257+ * A type expression representing the void type.
258+ *
259+ * Example:
260+ *
261+ * ```
262+ * void
263+ * ```
264+ */
172265class JSDocVoidTypeExpr extends @jsdoc_void_type_expr, JSDocTypeExpr {
173266 override predicate isVoid ( ) { any ( ) }
174267}
175268
176- /** A type expression referring to a named type. */
269+ /**
270+ * A type expression referring to a named type.
271+ *
272+ * Example:
273+ *
274+ * ```
275+ * string
276+ * Object
277+ * ```
278+ */
177279class JSDocNamedTypeExpr extends @jsdoc_named_type_expr, JSDocTypeExpr {
178280 /** Gets the name of the type the expression refers to. */
179281 string getName ( ) { result = toString ( ) }
@@ -268,7 +370,13 @@ class JSDocNamedTypeExpr extends @jsdoc_named_type_expr, JSDocTypeExpr {
268370}
269371
270372/**
271- * An applied type expression such as `Array<string>`.
373+ * An applied type expression.
374+ *
375+ * Example:
376+ *
377+ * ```
378+ * Array<string>
379+ * ```
272380 */
273381class JSDocAppliedTypeExpr extends @jsdoc_applied_type_expr, JSDocTypeExpr {
274382 /** Gets the head type expression, such as `Array` in `Array<string>`. */
@@ -298,7 +406,13 @@ class JSDocAppliedTypeExpr extends @jsdoc_applied_type_expr, JSDocTypeExpr {
298406}
299407
300408/**
301- * A nullable type expression such as `?number`.
409+ * A nullable type expression.
410+ *
411+ * Example:
412+ *
413+ * ```
414+ * ?Array
415+ * ```
302416 */
303417class JSDocNullableTypeExpr extends @jsdoc_nullable_type_expr, JSDocTypeExpr {
304418 /** Gets the argument type expression. */
@@ -315,7 +429,13 @@ class JSDocNullableTypeExpr extends @jsdoc_nullable_type_expr, JSDocTypeExpr {
315429}
316430
317431/**
318- * A non-nullable type expression such as `!number`.
432+ * A non-nullable type expression.
433+ *
434+ * Example:
435+ *
436+ * ```
437+ * !Array
438+ * ```
319439 */
320440class JSDocNonNullableTypeExpr extends @jsdoc_non_nullable_type_expr, JSDocTypeExpr {
321441 /** Gets the argument type expression. */
@@ -332,7 +452,13 @@ class JSDocNonNullableTypeExpr extends @jsdoc_non_nullable_type_expr, JSDocTypeE
332452}
333453
334454/**
335- * A record type expression such as `{ x: number, y: string }`.
455+ * A record type expression.
456+ *
457+ * Example:
458+ *
459+ * ```
460+ * { x: number, y: string }
461+ * ```
336462 */
337463class JSDocRecordTypeExpr extends @jsdoc_record_type_expr, JSDocTypeExpr {
338464 /** Gets the name of the `i`th field of the record type. */
@@ -351,7 +477,13 @@ class JSDocRecordTypeExpr extends @jsdoc_record_type_expr, JSDocTypeExpr {
351477}
352478
353479/**
354- * An array type expression such as `[string]`.
480+ * An array type expression.
481+ *
482+ * Example:
483+ *
484+ * ```
485+ * [string]
486+ * ```
355487 */
356488class JSDocArrayTypeExpr extends @jsdoc_array_type_expr, JSDocTypeExpr {
357489 /** Gets the type of the `i`th element of this array type. */
@@ -362,7 +494,13 @@ class JSDocArrayTypeExpr extends @jsdoc_array_type_expr, JSDocTypeExpr {
362494}
363495
364496/**
365- * A union type expression such as `number|string`.
497+ * A union type expression.
498+ *
499+ * Example:
500+ *
501+ * ```
502+ * number|string
503+ * ```
366504 */
367505class JSDocUnionTypeExpr extends @jsdoc_union_type_expr, JSDocTypeExpr {
368506 /** Gets one of the type alternatives of this union type. */
@@ -372,7 +510,13 @@ class JSDocUnionTypeExpr extends @jsdoc_union_type_expr, JSDocTypeExpr {
372510}
373511
374512/**
375- * A function type expression such as `function(string): number`.
513+ * A function type expression.
514+ *
515+ * Example:
516+ *
517+ * ```
518+ * function(string): number
519+ * ```
376520 */
377521class JSDocFunctionTypeExpr extends @jsdoc_function_type_expr, JSDocTypeExpr {
378522 /** Gets the result type of this function type. */
@@ -392,7 +536,13 @@ class JSDocFunctionTypeExpr extends @jsdoc_function_type_expr, JSDocTypeExpr {
392536}
393537
394538/**
395- * An optional parameter type such as `number=`.
539+ * An optional parameter type.
540+ *
541+ * Example:
542+ *
543+ * ```
544+ * number=
545+ * ```
396546 */
397547class JSDocOptionalParameterTypeExpr extends @jsdoc_optional_type_expr, JSDocTypeExpr {
398548 /** Gets the underlying type of this optional type. */
@@ -406,7 +556,13 @@ class JSDocOptionalParameterTypeExpr extends @jsdoc_optional_type_expr, JSDocTyp
406556}
407557
408558/**
409- * A rest parameter type such as `string...`.
559+ * A rest parameter type.
560+ *
561+ * Example:
562+ *
563+ * ```
564+ * string...
565+ * ```
410566 */
411567class JSDocRestParameterTypeExpr extends @jsdoc_rest_type_expr, JSDocTypeExpr {
412568 /** Gets the underlying type of this rest parameter type. */
0 commit comments