1 | import { TSDocTagDefinition, TSDocTagSyntaxKind } from '../configuration/TSDocTagDefinition';
|
2 | import { Standardization } from './Standardization';
|
3 | /**
|
4 | * Tags whose meaning is defined by the TSDoc standard.
|
5 | */
|
6 | var StandardTags = /** @class */ (function () {
|
7 | function StandardTags() {
|
8 | }
|
9 | StandardTags._defineTag = function (parameters) {
|
10 | return new TSDocTagDefinition(parameters);
|
11 | };
|
12 | /**
|
13 | * (Discretionary)
|
14 | *
|
15 | * Suggested meaning: Designates that an API item's release stage is "alpha".
|
16 | * It is intended to be used by third-party developers eventually, but has not
|
17 | * yet been released. The tooling may trim the declaration from a public release.
|
18 | *
|
19 | * @remarks
|
20 | * Example implementations: API Extractor
|
21 | */
|
22 | StandardTags.alpha = StandardTags._defineTag({
|
23 | tagName: '@alpha',
|
24 | syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
25 | standardization: Standardization.Discretionary
|
26 | });
|
27 | /**
|
28 | * (Discretionary)
|
29 | *
|
30 | * Suggested meaning: Designates that an API item's release stage is "beta".
|
31 | * It has been released to third-party developers experimentally for the purpose of
|
32 | * collecting feedback. The API should not be used in production, because its contract may
|
33 | * change without notice. The tooling may trim the declaration from a public release,
|
34 | * but may include it in a developer preview release.
|
35 | *
|
36 | * @remarks
|
37 | * Example implementations: API Extractor
|
38 | *
|
39 | * Synonyms: `@experimental`
|
40 | */
|
41 | StandardTags.beta = StandardTags._defineTag({
|
42 | tagName: '@beta',
|
43 | syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
44 | standardization: Standardization.Discretionary
|
45 | });
|
46 | /**
|
47 | * (Extended)
|
48 | *
|
49 | * ECMAScript decorators are sometimes an important part of an API contract.
|
50 | * However, today the TypeScript compiler does not represent decorators in the
|
51 | * .d.ts output files used by API consumers. The `@decorator` tag provides a workaround,
|
52 | * enabling a decorator expressions to be quoted in a doc comment.
|
53 | *
|
54 | * @example
|
55 | * ```ts
|
56 | * class Book {
|
57 | * /**
|
58 | * * The title of the book.
|
59 | * * @decorator `@jsonSerialized`
|
60 | * * @decorator `@jsonFormat(JsonFormats.Url)`
|
61 | * *
|
62 | *+/
|
63 | * @jsonSerialized
|
64 | * @jsonFormat(JsonFormats.Url)
|
65 | * public website: string;
|
66 | * }
|
67 | * ```
|
68 | */
|
69 | StandardTags.decorator = StandardTags._defineTag({
|
70 | tagName: '@decorator',
|
71 | syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
72 | allowMultiple: true,
|
73 | standardization: Standardization.Extended
|
74 | });
|
75 | /**
|
76 | * (Extended)
|
77 | *
|
78 | * This block tag is used to document the default value for a field or property,
|
79 | * if a value is not assigned explicitly.
|
80 | *
|
81 | * @remarks
|
82 | * This tag should only be used with fields or properties that are members of a class or interface.
|
83 | */
|
84 | StandardTags.defaultValue = StandardTags._defineTag({
|
85 | tagName: '@defaultValue',
|
86 | syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
87 | standardization: Standardization.Extended
|
88 | });
|
89 | /**
|
90 | * (Core)
|
91 | *
|
92 | * This block tag communicates that an API item is no longer supported and may be removed
|
93 | * in a future release. The `@deprecated` tag is followed by a sentence describing
|
94 | * the recommended alternative. It recursively applies to members of the container.
|
95 | * For example, if a class is deprecated, then so are all of its members.
|
96 | */
|
97 | StandardTags.deprecated = StandardTags._defineTag({
|
98 | tagName: '@deprecated',
|
99 | syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
100 | standardization: Standardization.Core
|
101 | });
|
102 | /**
|
103 | * (Extended)
|
104 | *
|
105 | * When applied to a class or interface property, this indicates that the property
|
106 | * returns an event object that event handlers can be attached to. The event-handling
|
107 | * API is implementation-defined, but typically the property return type would be a class
|
108 | * with members such as `addHandler()` and `removeHandler()`. A documentation tool can
|
109 | * display such properties under an "Events" heading instead of the usual "Properties" heading.
|
110 | */
|
111 | StandardTags.eventProperty = StandardTags._defineTag({
|
112 | tagName: '@eventProperty',
|
113 | syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
114 | standardization: Standardization.Extended
|
115 | });
|
116 | /**
|
117 | * (Extended)
|
118 | *
|
119 | * Indicates a documentation section that should be presented as an example
|
120 | * illustrating how to use the API. It may include a code sample.
|
121 | */
|
122 | StandardTags.example = StandardTags._defineTag({
|
123 | tagName: '@example',
|
124 | syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
125 | allowMultiple: true,
|
126 | standardization: Standardization.Extended
|
127 | });
|
128 | /**
|
129 | * (Discretionary)
|
130 | *
|
131 | * Suggested meaning: Same semantics as `@beta`, but used by tools that don't support
|
132 | * an `@alpha` release stage.
|
133 | *
|
134 | * @remarks
|
135 | * Example implementations: Angular API documenter
|
136 | *
|
137 | * Synonyms: `@beta`
|
138 | */
|
139 | StandardTags.experimental = StandardTags._defineTag({
|
140 | tagName: '@experimental',
|
141 | syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
142 | standardization: Standardization.Discretionary
|
143 | });
|
144 | /**
|
145 | * (Extended)
|
146 | *
|
147 | * This inline tag is used to automatically generate an API item's documentation by
|
148 | * copying it from another API item. The inline tag parameter contains a reference
|
149 | * to the other item, which may be an unrelated class, or even an import from a
|
150 | * separate NPM package.
|
151 | *
|
152 | * @remarks
|
153 | * What gets copied
|
154 | *
|
155 | * The `@inheritDoc` tag does not copy the entire comment body. Only the following
|
156 | * components are copied:
|
157 | * - summary section
|
158 | * - `@remarks` block
|
159 | * - `@params` blocks
|
160 | * - `@typeParam` blocks
|
161 | * - `@returns` block
|
162 | * Other tags such as `@defaultValue` or `@example` are not copied, and need to be
|
163 | * explicitly included after the `@inheritDoc` tag.
|
164 | *
|
165 | * TODO: The notation for API item references is still being standardized. See this issue:
|
166 | * https://github.com/microsoft/tsdoc/issues/9
|
167 | */
|
168 | StandardTags.inheritDoc = StandardTags._defineTag({
|
169 | tagName: '@inheritDoc',
|
170 | syntaxKind: TSDocTagSyntaxKind.InlineTag,
|
171 | standardization: Standardization.Extended
|
172 | });
|
173 | /**
|
174 | * (Discretionary)
|
175 | *
|
176 | * Suggested meaning: Designates that an API item is not planned to be used by
|
177 | * third-party developers. The tooling may trim the declaration from a public release.
|
178 | * In some implementations, certain designated packages may be allowed to consume
|
179 | * internal API items, e.g. because the packages are components of the same product.
|
180 | *
|
181 | * @remarks
|
182 | * Example implementations: API Extractor
|
183 | */
|
184 | StandardTags.internal = StandardTags._defineTag({
|
185 | tagName: '@internal',
|
186 | syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
187 | standardization: Standardization.Discretionary
|
188 | });
|
189 | /**
|
190 | * (Core)
|
191 | *
|
192 | * The `{@label}` inline tag is used to label a declaration, so that it can be referenced
|
193 | * using a selector in the TSDoc declaration reference notation.
|
194 | *
|
195 | * @remarks
|
196 | * TODO: The `{@label}` notation is still being standardized. See this issue:
|
197 | * https://github.com/microsoft/tsdoc/issues/9
|
198 | */
|
199 | StandardTags.label = StandardTags._defineTag({
|
200 | tagName: '@label',
|
201 | syntaxKind: TSDocTagSyntaxKind.InlineTag,
|
202 | standardization: Standardization.Core
|
203 | });
|
204 | /**
|
205 | * (Core)
|
206 | *
|
207 | * The `{@link}` inline tag is used to create hyperlinks to other pages in a
|
208 | * documentation system or general internet URLs. In particular, it supports
|
209 | * expressions for referencing API items.
|
210 | *
|
211 | * @remarks
|
212 | * TODO: The `{@link}` notation is still being standardized. See this issue:
|
213 | * https://github.com/microsoft/tsdoc/issues/9
|
214 | */
|
215 | StandardTags.link = StandardTags._defineTag({
|
216 | tagName: '@link',
|
217 | syntaxKind: TSDocTagSyntaxKind.InlineTag,
|
218 | allowMultiple: true,
|
219 | standardization: Standardization.Core
|
220 | });
|
221 | /**
|
222 | * (Extended)
|
223 | *
|
224 | * This modifier has similar semantics to the `override` keyword in C# or Java.
|
225 | * For a member function or property, explicitly indicates that this definition
|
226 | * is overriding (i.e. redefining) the definition inherited from the base class.
|
227 | * The base class definition would normally be marked as `virtual`.
|
228 | *
|
229 | * @remarks
|
230 | * A documentation tool may enforce that the `@virtual`, `@override`, and/or `@sealed`
|
231 | * modifiers are consistently applied, but this is not required by the TSDoc standard.
|
232 | */
|
233 | StandardTags.override = StandardTags._defineTag({
|
234 | tagName: '@override',
|
235 | syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
236 | standardization: Standardization.Extended
|
237 | });
|
238 | /**
|
239 | * (Core)
|
240 | *
|
241 | * Used to indicate a doc comment that describes an entire NPM package (as opposed
|
242 | * to an individual API item belonging to that package). The `@packageDocumentation` comment
|
243 | * is found in the *.d.ts file that acts as the entry point for the package, and it
|
244 | * should be the first `/**` comment encountered in that file. A comment containing a
|
245 | * `@packageDocumentation` tag should never be used to describe an individual API item.
|
246 | */
|
247 | StandardTags.packageDocumentation = StandardTags._defineTag({
|
248 | tagName: '@packageDocumentation',
|
249 | syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
250 | standardization: Standardization.Core
|
251 | });
|
252 | /**
|
253 | * (Core)
|
254 | *
|
255 | * Used to document a function parameter. The `@param` tag is followed by a parameter
|
256 | * name, followed by a hyphen, followed by a description. The TSDoc parser recognizes
|
257 | * this syntax and will extract it into a DocParamBlock node.
|
258 | */
|
259 | StandardTags.param = StandardTags._defineTag({
|
260 | tagName: '@param',
|
261 | syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
262 | allowMultiple: true,
|
263 | standardization: Standardization.Core
|
264 | });
|
265 | /**
|
266 | * (Core)
|
267 | *
|
268 | * Starts a section of additional documentation content that is not intended for a
|
269 | * public audience. A tool must omit this entire section from the API reference web site,
|
270 | * generated *.d.ts file, and any other outputs incorporating the content.
|
271 | */
|
272 | StandardTags.privateRemarks = StandardTags._defineTag({
|
273 | tagName: '@privateRemarks',
|
274 | syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
275 | standardization: Standardization.Core
|
276 | });
|
277 | /**
|
278 | * (Discretionary)
|
279 | *
|
280 | * Suggested meaning: Designates that an API item's release stage is "public".
|
281 | * It has been officially released to third-party developers, and its signature is
|
282 | * guaranteed to be stable (e.g. following Semantic Versioning rules).
|
283 | *
|
284 | * @remarks
|
285 | * Example implementations: API Extractor
|
286 | */
|
287 | StandardTags.public = StandardTags._defineTag({
|
288 | tagName: '@public',
|
289 | syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
290 | standardization: Standardization.Discretionary
|
291 | });
|
292 | /**
|
293 | * (Extended)
|
294 | *
|
295 | * This modifier tag indicates that an API item should be documented as being read-only,
|
296 | * even if the TypeScript type system may indicate otherwise. For example, suppose a
|
297 | * class property has a setter function that always throws an exception explaining that
|
298 | * the property cannot be assigned; in this situation, the `@readonly` modifier can be
|
299 | * added so that the property is shown as read-only in the documentation.
|
300 | *
|
301 | * @remarks
|
302 | * Example implementations: API Extractor
|
303 | */
|
304 | StandardTags.readonly = StandardTags._defineTag({
|
305 | tagName: '@readonly',
|
306 | syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
307 | standardization: Standardization.Extended
|
308 | });
|
309 | /**
|
310 | * (Core)
|
311 | *
|
312 | * The main documentation for an API item is separated into a brief "summary" section,
|
313 | * optionally followed by a more detailed "remarks" section. On a documentation web site,
|
314 | * index pages (e.g. showing members of a class) will show only the brief summaries,
|
315 | * whereas a detail pages (e.g. describing a single member) will show the summary followed
|
316 | * by the remarks. The `@remarks` block tag ends the summary section, and begins the
|
317 | * remarks section for a doc comment.
|
318 | */
|
319 | StandardTags.remarks = StandardTags._defineTag({
|
320 | tagName: '@remarks',
|
321 | syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
322 | standardization: Standardization.Core
|
323 | });
|
324 | /**
|
325 | * (Core)
|
326 | *
|
327 | * Used to document the return value for a function.
|
328 | */
|
329 | StandardTags.returns = StandardTags._defineTag({
|
330 | tagName: '@returns',
|
331 | syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
332 | standardization: Standardization.Core
|
333 | });
|
334 | /**
|
335 | * (Extended)
|
336 | *
|
337 | * This modifier has similar semantics to the `sealed` keyword in C# or Java.
|
338 | * For a class, indicates that subclasses must not inherit from the class.
|
339 | * For a member function or property, indicates that subclasses must not override
|
340 | * (i.e. redefine) the member.
|
341 | *
|
342 | * @remarks
|
343 | * A documentation tool may enforce that the `@virtual`, `@override`, and/or `@sealed`
|
344 | * modifiers are consistently applied, but this is not required by the TSDoc standard.
|
345 | */
|
346 | StandardTags.sealed = StandardTags._defineTag({
|
347 | tagName: '@sealed',
|
348 | syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
349 | standardization: Standardization.Extended
|
350 | });
|
351 | /**
|
352 | * (Extended)
|
353 | *
|
354 | * Used to build a list of references to an API item or other resource that may be related to the
|
355 | * current item.
|
356 | *
|
357 | * @remarks
|
358 | *
|
359 | * For example:
|
360 | *
|
361 | * ```ts
|
362 | * /**
|
363 | * * Parses a string containing a Uniform Resource Locator (URL).
|
364 | * * @see {@link ParsedUrl} for the returned data structure
|
365 | * * @see {@link https://tools.ietf.org/html/rfc1738|RFC 1738}
|
366 | * * for syntax
|
367 | * * @see your developer SDK for code samples
|
368 | * * @param url - the string to be parsed
|
369 | * * @returns the parsed result
|
370 | * */
|
371 | * function parseURL(url: string): ParsedUrl;
|
372 | * ```
|
373 | *
|
374 | * `@see` is a block tag. Each block becomes an item in the list of references. For example, a documentation
|
375 | * system might render the above blocks as follows:
|
376 | *
|
377 | * ```markdown
|
378 | * `function parseURL(url: string): ParsedUrl;`
|
379 | *
|
380 | * Parses a string containing a Uniform Resource Locator (URL).
|
381 | *
|
382 | * ## See Also
|
383 | * - ParsedUrl for the returned data structure
|
384 | * - RFC 1738 for syntax
|
385 | * - your developer SDK for code samples
|
386 | * ```
|
387 | *
|
388 | * NOTE: JSDoc attempts to automatically hyperlink the text immediately after `@see`. Because this is ambiguous
|
389 | * with plain text, TSDoc instead requires an explicit `{@link}` tag to make hyperlinks.
|
390 | */
|
391 | StandardTags.see = StandardTags._defineTag({
|
392 | tagName: '@see',
|
393 | syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
394 | standardization: Standardization.Extended
|
395 | });
|
396 | /**
|
397 | * (Extended)
|
398 | *
|
399 | * Used to document an exception type that may be thrown by a function or property.
|
400 | *
|
401 | * @remarks
|
402 | *
|
403 | * A separate `@throws` block should be used to document each exception type. This tag is for informational
|
404 | * purposes only, and does not restrict other types from being thrown. It is suggested, but not required,
|
405 | * for the `@throws` block to start with a line containing only the name of the exception.
|
406 | *
|
407 | * For example:
|
408 | *
|
409 | * ```ts
|
410 | * /**
|
411 | * * Retrieves metadata about a book from the catalog.
|
412 | * *
|
413 | * * @param isbnCode - the ISBN number for the book
|
414 | * * @returns the retrieved book object
|
415 | * *
|
416 | * * @throws {@link IsbnSyntaxError}
|
417 | * * This exception is thrown if the input is not a valid ISBN number.
|
418 | * *
|
419 | * * @throws {@link book-lib#BookNotFoundError}
|
420 | * * Thrown if the ISBN number is valid, but no such book exists in the catalog.
|
421 | * *
|
422 | * * @public
|
423 | * */
|
424 | * function fetchBookByIsbn(isbnCode: string): Book;
|
425 | * ```
|
426 | */
|
427 | StandardTags.throws = StandardTags._defineTag({
|
428 | tagName: '@throws',
|
429 | syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
430 | allowMultiple: true,
|
431 | standardization: Standardization.Extended
|
432 | });
|
433 | /**
|
434 | * (Core)
|
435 | *
|
436 | * Used to document a generic parameter. The `@typeParam` tag is followed by a parameter
|
437 | * name, followed by a hyphen, followed by a description. The TSDoc parser recognizes
|
438 | * this syntax and will extract it into a DocParamBlock node.
|
439 | */
|
440 | StandardTags.typeParam = StandardTags._defineTag({
|
441 | tagName: '@typeParam',
|
442 | syntaxKind: TSDocTagSyntaxKind.BlockTag,
|
443 | allowMultiple: true,
|
444 | standardization: Standardization.Core
|
445 | });
|
446 | /**
|
447 | * (Extended)
|
448 | *
|
449 | * This modifier has similar semantics to the `virtual` keyword in C# or Java.
|
450 | * For a member function or property, explicitly indicates that subclasses may override
|
451 | * (i.e. redefine) the member.
|
452 | *
|
453 | * @remarks
|
454 | * A documentation tool may enforce that the `@virtual`, `@override`, and/or `@sealed`
|
455 | * modifiers are consistently applied, but this is not required by the TSDoc standard.
|
456 | */
|
457 | StandardTags.virtual = StandardTags._defineTag({
|
458 | tagName: '@virtual',
|
459 | syntaxKind: TSDocTagSyntaxKind.ModifierTag,
|
460 | standardization: Standardization.Extended
|
461 | });
|
462 | /**
|
463 | * Returns the full list of all core tags.
|
464 | */
|
465 | StandardTags.allDefinitions = [
|
466 | StandardTags.alpha,
|
467 | StandardTags.beta,
|
468 | StandardTags.defaultValue,
|
469 | StandardTags.decorator,
|
470 | StandardTags.deprecated,
|
471 | StandardTags.eventProperty,
|
472 | StandardTags.example,
|
473 | StandardTags.experimental,
|
474 | StandardTags.inheritDoc,
|
475 | StandardTags.internal,
|
476 | StandardTags.label,
|
477 | StandardTags.link,
|
478 | StandardTags.override,
|
479 | StandardTags.packageDocumentation,
|
480 | StandardTags.param,
|
481 | StandardTags.privateRemarks,
|
482 | StandardTags.public,
|
483 | StandardTags.readonly,
|
484 | StandardTags.remarks,
|
485 | StandardTags.returns,
|
486 | StandardTags.sealed,
|
487 | StandardTags.see,
|
488 | StandardTags.throws,
|
489 | StandardTags.typeParam,
|
490 | StandardTags.virtual
|
491 | ];
|
492 | return StandardTags;
|
493 | }());
|
494 | export { StandardTags };
|
495 | //# sourceMappingURL=StandardTags.js.map |
\ | No newline at end of file |