ts-japi 1.12.1 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.commitlintrc.ts +1 -1
- package/.github/workflows/ci.yml +32 -0
- package/.github/workflows/release-notes.yml +53 -0
- package/.github/workflows/{release-please.yaml → release-please.yml} +6 -7
- package/.github/workflows/release.yml +147 -0
- package/.node-version +1 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +7 -0
- package/LICENSE +2 -1
- package/README.md +9 -7
- package/benchmarks/playground.benchmark.ts +12 -12
- package/benchmarks/serializer.benchmark.ts +10 -10
- package/biome.json +141 -0
- package/lefthook.yml +12 -0
- package/lib/classes/cache.d.ts +4 -4
- package/lib/classes/cache.d.ts.map +1 -1
- package/lib/classes/cache.js +7 -5
- package/lib/classes/cache.js.map +1 -1
- package/lib/classes/error-serializer.d.ts +3 -3
- package/lib/classes/error-serializer.d.ts.map +1 -1
- package/lib/classes/error-serializer.js +18 -15
- package/lib/classes/error-serializer.js.map +1 -1
- package/lib/classes/linker.d.ts +3 -3
- package/lib/classes/linker.d.ts.map +1 -1
- package/lib/classes/metaizer.d.ts +2 -2
- package/lib/classes/metaizer.d.ts.map +1 -1
- package/lib/classes/paginator.d.ts +5 -5
- package/lib/classes/paginator.d.ts.map +1 -1
- package/lib/classes/paginator.js +6 -5
- package/lib/classes/paginator.js.map +1 -1
- package/lib/classes/polymorphic-serialiser.d.ts +9 -10
- package/lib/classes/polymorphic-serialiser.d.ts.map +1 -1
- package/lib/classes/polymorphic-serialiser.js +15 -6
- package/lib/classes/polymorphic-serialiser.js.map +1 -1
- package/lib/classes/relator.d.ts +11 -11
- package/lib/classes/relator.d.ts.map +1 -1
- package/lib/classes/relator.js +15 -6
- package/lib/classes/relator.js.map +1 -1
- package/lib/classes/serializer.d.ts +9 -9
- package/lib/classes/serializer.d.ts.map +1 -1
- package/lib/classes/serializer.js +38 -27
- package/lib/classes/serializer.js.map +1 -1
- package/lib/index.d.ts +21 -21
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -9
- package/lib/index.js.map +1 -1
- package/lib/interfaces/cache.interface.d.ts +1 -1
- package/lib/interfaces/cache.interface.d.ts.map +1 -1
- package/lib/interfaces/error-serializer.interface.d.ts +37 -37
- package/lib/interfaces/error-serializer.interface.d.ts.map +1 -1
- package/lib/interfaces/error.interface.d.ts +21 -21
- package/lib/interfaces/error.interface.d.ts.map +1 -1
- package/lib/interfaces/json-api.interface.d.ts +12 -12
- package/lib/interfaces/json-api.interface.d.ts.map +1 -1
- package/lib/interfaces/linker.interface.d.ts +1 -1
- package/lib/interfaces/linker.interface.d.ts.map +1 -1
- package/lib/interfaces/paginator.interface.d.ts +2 -2
- package/lib/interfaces/paginator.interface.d.ts.map +1 -1
- package/lib/interfaces/relator.interface.d.ts +3 -3
- package/lib/interfaces/relator.interface.d.ts.map +1 -1
- package/lib/interfaces/serializer.interface.d.ts +78 -78
- package/lib/interfaces/serializer.interface.d.ts.map +1 -1
- package/lib/models/error.model.d.ts +4 -4
- package/lib/models/error.model.d.ts.map +1 -1
- package/lib/models/error.model.js +29 -18
- package/lib/models/error.model.js.map +1 -1
- package/lib/models/link.model.d.ts +1 -1
- package/lib/models/link.model.d.ts.map +1 -1
- package/lib/models/relationship.model.d.ts +5 -5
- package/lib/models/relationship.model.d.ts.map +1 -1
- package/lib/models/relationship.model.js +8 -5
- package/lib/models/relationship.model.js.map +1 -1
- package/lib/models/resource-identifier.model.d.ts +1 -1
- package/lib/models/resource-identifier.model.d.ts.map +1 -1
- package/lib/models/resource-identifier.model.js +2 -1
- package/lib/models/resource-identifier.model.js.map +1 -1
- package/lib/models/resource.model.d.ts +5 -5
- package/lib/models/resource.model.d.ts.map +1 -1
- package/lib/models/resource.model.js +6 -3
- package/lib/models/resource.model.js.map +1 -1
- package/lib/types/global.types.d.ts +9 -9
- package/lib/types/global.types.d.ts.map +1 -1
- package/lib/utils/is-error-document.d.ts +1 -1
- package/lib/utils/is-error-document.d.ts.map +1 -1
- package/lib/utils/is-error-document.js +3 -4
- package/lib/utils/is-error-document.js.map +1 -1
- package/lib/utils/is-object.d.ts.map +1 -1
- package/lib/utils/is-object.js +3 -3
- package/lib/utils/is-object.js.map +1 -1
- package/lib/utils/is-plain-object.d.ts.map +1 -1
- package/lib/utils/is-plain-object.js +9 -6
- package/lib/utils/is-plain-object.js.map +1 -1
- package/lib/utils/merge.d.ts +1 -1
- package/lib/utils/merge.d.ts.map +1 -1
- package/lib/utils/merge.js +5 -3
- package/lib/utils/merge.js.map +1 -1
- package/lib/utils/serializer.utils.d.ts +4 -4
- package/lib/utils/serializer.utils.d.ts.map +1 -1
- package/lib/utils/serializer.utils.js +27 -22
- package/lib/utils/serializer.utils.js.map +1 -1
- package/package.json +53 -65
- package/release-please-config.json +8 -3
- package/tools/generate_docs.ts +7 -9
- package/tools/internal/custom_markdown_action.ts +3 -3
- package/tools/internal/custom_markdown_documenter.ts +348 -244
- package/tsconfig.json +4 -3
- package/.github/release-please.yml +0 -4
- package/.github/workflows/ci.yaml +0 -73
- package/.github/workflows/publish.yaml +0 -29
- package/.husky/pre-commit +0 -4
- package/.husky/pre-push +0 -4
- package/.prettierignore +0 -4
- package/.prettierrc +0 -10
|
@@ -21,19 +21,36 @@
|
|
|
21
21
|
// https://github.com/microsoft/rushstack/blob/main/apps/api-documenter/src/documenters/MarkdownDocumenter.ts
|
|
22
22
|
// This file has been edited to morph into Docusaurus's expected inputs.
|
|
23
23
|
|
|
24
|
+
import * as path from "node:path";
|
|
25
|
+
import type { DocumenterConfig } from "@microsoft/api-documenter/lib/documenters/DocumenterConfig";
|
|
26
|
+
import { CustomMarkdownEmitter } from "@microsoft/api-documenter/lib/markdown/CustomMarkdownEmitter";
|
|
27
|
+
import { CustomDocNodes } from "@microsoft/api-documenter/lib/nodes/CustomDocNodeKind";
|
|
28
|
+
import { DocEmphasisSpan } from "@microsoft/api-documenter/lib/nodes/DocEmphasisSpan";
|
|
29
|
+
import { DocHeading } from "@microsoft/api-documenter/lib/nodes/DocHeading";
|
|
30
|
+
import { DocNoteBox } from "@microsoft/api-documenter/lib/nodes/DocNoteBox";
|
|
31
|
+
import { DocTable } from "@microsoft/api-documenter/lib/nodes/DocTable";
|
|
32
|
+
import { DocTableCell } from "@microsoft/api-documenter/lib/nodes/DocTableCell";
|
|
33
|
+
import { DocTableRow } from "@microsoft/api-documenter/lib/nodes/DocTableRow";
|
|
34
|
+
import { MarkdownDocumenterAccessor } from "@microsoft/api-documenter/lib/plugin/MarkdownDocumenterAccessor";
|
|
35
|
+
import {
|
|
36
|
+
type IMarkdownDocumenterFeatureOnBeforeWritePageArgs,
|
|
37
|
+
MarkdownDocumenterFeatureContext,
|
|
38
|
+
} from "@microsoft/api-documenter/lib/plugin/MarkdownDocumenterFeature";
|
|
39
|
+
import { PluginLoader } from "@microsoft/api-documenter/lib/plugin/PluginLoader";
|
|
40
|
+
import { Utilities } from "@microsoft/api-documenter/lib/utils/Utilities";
|
|
24
41
|
import {
|
|
25
42
|
ApiClass,
|
|
26
43
|
ApiDeclaredItem,
|
|
27
44
|
ApiDocumentedItem,
|
|
28
|
-
ApiEnum,
|
|
45
|
+
type ApiEnum,
|
|
29
46
|
ApiInitializerMixin,
|
|
30
47
|
ApiInterface,
|
|
31
|
-
ApiItem,
|
|
48
|
+
type ApiItem,
|
|
32
49
|
ApiItemKind,
|
|
33
|
-
ApiModel,
|
|
34
|
-
ApiNamespace,
|
|
50
|
+
type ApiModel,
|
|
51
|
+
type ApiNamespace,
|
|
35
52
|
ApiOptionalMixin,
|
|
36
|
-
ApiPackage,
|
|
53
|
+
type ApiPackage,
|
|
37
54
|
ApiParameterListMixin,
|
|
38
55
|
ApiPropertyItem,
|
|
39
56
|
ApiProtectedMixin,
|
|
@@ -42,46 +59,32 @@ import {
|
|
|
42
59
|
ApiReturnTypeMixin,
|
|
43
60
|
ApiStaticMixin,
|
|
44
61
|
ApiTypeAlias,
|
|
45
|
-
Excerpt,
|
|
46
|
-
ExcerptToken,
|
|
62
|
+
type Excerpt,
|
|
63
|
+
type ExcerptToken,
|
|
47
64
|
ExcerptTokenKind,
|
|
48
|
-
IResolveDeclarationReferenceResult,
|
|
65
|
+
type IResolveDeclarationReferenceResult,
|
|
49
66
|
ReleaseTag,
|
|
50
|
-
} from
|
|
67
|
+
} from "@microsoft/api-extractor-model";
|
|
51
68
|
import {
|
|
52
|
-
DocBlock,
|
|
69
|
+
type DocBlock,
|
|
53
70
|
DocCodeSpan,
|
|
54
|
-
DocComment,
|
|
71
|
+
type DocComment,
|
|
55
72
|
DocFencedCode,
|
|
56
73
|
DocLinkTag,
|
|
57
|
-
DocNodeContainer,
|
|
74
|
+
type DocNodeContainer,
|
|
58
75
|
DocNodeKind,
|
|
59
76
|
DocParagraph,
|
|
60
77
|
DocPlainText,
|
|
61
78
|
DocSection,
|
|
62
79
|
StandardTags,
|
|
63
80
|
StringBuilder,
|
|
64
|
-
TSDocConfiguration,
|
|
65
|
-
} from
|
|
66
|
-
import { FileSystem, NewlineKind, PackageName } from '@rushstack/node-core-library';
|
|
67
|
-
import * as path from 'path';
|
|
68
|
-
|
|
69
|
-
import { DocumenterConfig } from '@microsoft/api-documenter/lib/documenters/DocumenterConfig';
|
|
70
|
-
import { CustomMarkdownEmitter } from '@microsoft/api-documenter/lib/markdown/CustomMarkdownEmitter';
|
|
71
|
-
import { CustomDocNodes } from '@microsoft/api-documenter/lib/nodes/CustomDocNodeKind';
|
|
72
|
-
import { DocEmphasisSpan } from '@microsoft/api-documenter/lib/nodes/DocEmphasisSpan';
|
|
73
|
-
import { DocHeading } from '@microsoft/api-documenter/lib/nodes/DocHeading';
|
|
74
|
-
import { DocNoteBox } from '@microsoft/api-documenter/lib/nodes/DocNoteBox';
|
|
75
|
-
import { DocTable } from '@microsoft/api-documenter/lib/nodes/DocTable';
|
|
76
|
-
import { DocTableCell } from '@microsoft/api-documenter/lib/nodes/DocTableCell';
|
|
77
|
-
import { DocTableRow } from '@microsoft/api-documenter/lib/nodes/DocTableRow';
|
|
78
|
-
import { MarkdownDocumenterAccessor } from '@microsoft/api-documenter/lib/plugin/MarkdownDocumenterAccessor';
|
|
81
|
+
type TSDocConfiguration,
|
|
82
|
+
} from "@microsoft/tsdoc";
|
|
79
83
|
import {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
import { Utilities } from '@microsoft/api-documenter/lib/utils/Utilities';
|
|
84
|
+
FileSystem,
|
|
85
|
+
NewlineKind,
|
|
86
|
+
PackageName,
|
|
87
|
+
} from "@rushstack/node-core-library";
|
|
85
88
|
|
|
86
89
|
export interface IMarkdownDocumenterOptions {
|
|
87
90
|
apiModel: ApiModel;
|
|
@@ -146,13 +149,19 @@ export class MarkdownDocumenter {
|
|
|
146
149
|
|
|
147
150
|
switch (apiItem.kind) {
|
|
148
151
|
case ApiItemKind.Class:
|
|
149
|
-
output.appendNode(
|
|
152
|
+
output.appendNode(
|
|
153
|
+
new DocHeading({ configuration, title: `${scopedName} class` })
|
|
154
|
+
);
|
|
150
155
|
break;
|
|
151
156
|
case ApiItemKind.Enum:
|
|
152
|
-
output.appendNode(
|
|
157
|
+
output.appendNode(
|
|
158
|
+
new DocHeading({ configuration, title: `${scopedName} enum` })
|
|
159
|
+
);
|
|
153
160
|
break;
|
|
154
161
|
case ApiItemKind.Interface:
|
|
155
|
-
output.appendNode(
|
|
162
|
+
output.appendNode(
|
|
163
|
+
new DocHeading({ configuration, title: `${scopedName} interface` })
|
|
164
|
+
);
|
|
156
165
|
break;
|
|
157
166
|
case ApiItemKind.Constructor:
|
|
158
167
|
case ApiItemKind.ConstructSignature:
|
|
@@ -160,44 +169,59 @@ export class MarkdownDocumenter {
|
|
|
160
169
|
break;
|
|
161
170
|
case ApiItemKind.Method:
|
|
162
171
|
case ApiItemKind.MethodSignature:
|
|
163
|
-
output.appendNode(
|
|
172
|
+
output.appendNode(
|
|
173
|
+
new DocHeading({ configuration, title: `${scopedName} method` })
|
|
174
|
+
);
|
|
164
175
|
break;
|
|
165
176
|
case ApiItemKind.Function:
|
|
166
|
-
output.appendNode(
|
|
177
|
+
output.appendNode(
|
|
178
|
+
new DocHeading({ configuration, title: `${scopedName} function` })
|
|
179
|
+
);
|
|
167
180
|
break;
|
|
168
181
|
case ApiItemKind.Model:
|
|
169
|
-
output.appendNode(
|
|
182
|
+
output.appendNode(
|
|
183
|
+
new DocHeading({ configuration, title: "API Reference" })
|
|
184
|
+
);
|
|
170
185
|
break;
|
|
171
186
|
case ApiItemKind.Namespace:
|
|
172
|
-
output.appendNode(
|
|
187
|
+
output.appendNode(
|
|
188
|
+
new DocHeading({ configuration, title: `${scopedName} namespace` })
|
|
189
|
+
);
|
|
173
190
|
break;
|
|
174
191
|
case ApiItemKind.Package:
|
|
175
192
|
console.log(`Writing ${apiItem.displayName} package`);
|
|
176
193
|
output.appendNode(
|
|
177
194
|
new DocHeading({
|
|
178
195
|
configuration,
|
|
179
|
-
title:
|
|
196
|
+
title: "API Reference",
|
|
180
197
|
})
|
|
181
198
|
);
|
|
182
199
|
break;
|
|
183
200
|
case ApiItemKind.Property:
|
|
184
201
|
case ApiItemKind.PropertySignature:
|
|
185
|
-
output.appendNode(
|
|
202
|
+
output.appendNode(
|
|
203
|
+
new DocHeading({ configuration, title: `${scopedName} property` })
|
|
204
|
+
);
|
|
186
205
|
break;
|
|
187
206
|
case ApiItemKind.TypeAlias:
|
|
188
|
-
output.appendNode(
|
|
207
|
+
output.appendNode(
|
|
208
|
+
new DocHeading({ configuration, title: `${scopedName} type` })
|
|
209
|
+
);
|
|
189
210
|
break;
|
|
190
211
|
case ApiItemKind.Variable:
|
|
191
|
-
output.appendNode(
|
|
212
|
+
output.appendNode(
|
|
213
|
+
new DocHeading({ configuration, title: `${scopedName} variable` })
|
|
214
|
+
);
|
|
192
215
|
break;
|
|
193
216
|
default:
|
|
194
|
-
throw new Error(
|
|
217
|
+
throw new Error(`Unsupported API item kind: ${apiItem.kind}`);
|
|
195
218
|
}
|
|
196
219
|
|
|
197
|
-
if (
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
220
|
+
if (
|
|
221
|
+
ApiReleaseTagMixin.isBaseClassOf(apiItem) &&
|
|
222
|
+
apiItem.releaseTag === ReleaseTag.Beta
|
|
223
|
+
) {
|
|
224
|
+
this._writeBetaWarning(output);
|
|
201
225
|
}
|
|
202
226
|
|
|
203
227
|
const decoratorBlocks: DocBlock[] = [];
|
|
@@ -209,7 +233,8 @@ export class MarkdownDocumenter {
|
|
|
209
233
|
decoratorBlocks.push(
|
|
210
234
|
...tsdocComment.customBlocks.filter((block) => {
|
|
211
235
|
return (
|
|
212
|
-
block.blockTag.tagNameWithUpperCase ===
|
|
236
|
+
block.blockTag.tagNameWithUpperCase ===
|
|
237
|
+
StandardTags.decorator.tagNameWithUpperCase
|
|
213
238
|
);
|
|
214
239
|
})
|
|
215
240
|
);
|
|
@@ -220,7 +245,7 @@ export class MarkdownDocumenter {
|
|
|
220
245
|
new DocParagraph({ configuration: this._tsdocConfiguration }, [
|
|
221
246
|
new DocPlainText({
|
|
222
247
|
configuration: this._tsdocConfiguration,
|
|
223
|
-
text:
|
|
248
|
+
text: "Warning: This API is now obsolete. ",
|
|
224
249
|
}),
|
|
225
250
|
]),
|
|
226
251
|
...tsdocComment.deprecatedBlock.content.nodes,
|
|
@@ -237,7 +262,7 @@ export class MarkdownDocumenter {
|
|
|
237
262
|
output.appendNode(
|
|
238
263
|
new DocParagraph({ configuration }, [
|
|
239
264
|
new DocEmphasisSpan({ configuration, bold: true }, [
|
|
240
|
-
new DocPlainText({ configuration, text:
|
|
265
|
+
new DocPlainText({ configuration, text: "Signature:" }),
|
|
241
266
|
]),
|
|
242
267
|
])
|
|
243
268
|
);
|
|
@@ -256,8 +281,8 @@ export class MarkdownDocumenter {
|
|
|
256
281
|
output.appendNode(
|
|
257
282
|
new DocFencedCode({
|
|
258
283
|
configuration,
|
|
259
|
-
code
|
|
260
|
-
language:
|
|
284
|
+
code,
|
|
285
|
+
language: "typescript",
|
|
261
286
|
})
|
|
262
287
|
);
|
|
263
288
|
}
|
|
@@ -269,7 +294,7 @@ export class MarkdownDocumenter {
|
|
|
269
294
|
output.appendNode(
|
|
270
295
|
new DocParagraph({ configuration }, [
|
|
271
296
|
new DocEmphasisSpan({ configuration, bold: true }, [
|
|
272
|
-
new DocPlainText({ configuration, text:
|
|
297
|
+
new DocPlainText({ configuration, text: "Decorators:" }),
|
|
273
298
|
]),
|
|
274
299
|
])
|
|
275
300
|
);
|
|
@@ -324,14 +349,17 @@ export class MarkdownDocumenter {
|
|
|
324
349
|
case ApiItemKind.Variable:
|
|
325
350
|
break;
|
|
326
351
|
default:
|
|
327
|
-
throw new Error(
|
|
352
|
+
throw new Error(`Unsupported API item kind: ${apiItem.kind}`);
|
|
328
353
|
}
|
|
329
354
|
|
|
330
355
|
if (appendRemarks) {
|
|
331
356
|
this._writeRemarksSection(output, apiItem);
|
|
332
357
|
}
|
|
333
358
|
|
|
334
|
-
const filename: string = path.join(
|
|
359
|
+
const filename: string = path.join(
|
|
360
|
+
this._outputFolder,
|
|
361
|
+
this._getFilenameForApiItem(apiItem)
|
|
362
|
+
);
|
|
335
363
|
const stringBuilder: StringBuilder = new StringBuilder();
|
|
336
364
|
|
|
337
365
|
this._markdownEmitter.emit(stringBuilder, output, {
|
|
@@ -346,19 +374,20 @@ export class MarkdownDocumenter {
|
|
|
346
374
|
if (this._pluginLoader.markdownDocumenterFeature) {
|
|
347
375
|
// Allow the plugin to customize the pageContent
|
|
348
376
|
const eventArgs: IMarkdownDocumenterFeatureOnBeforeWritePageArgs = {
|
|
349
|
-
apiItem
|
|
377
|
+
apiItem,
|
|
350
378
|
outputFilename: filename,
|
|
351
|
-
pageContent
|
|
379
|
+
pageContent,
|
|
352
380
|
};
|
|
353
381
|
this._pluginLoader.markdownDocumenterFeature.onBeforeWritePage(eventArgs);
|
|
354
382
|
pageContent = eventArgs.pageContent;
|
|
355
383
|
}
|
|
356
384
|
|
|
357
385
|
pageContent =
|
|
358
|
-
`---\nsidebar_label: ${this._getSidebarLabelForApiItem(apiItem)}\n---` +
|
|
359
|
-
|
|
360
|
-
pageContent = pageContent.replace(
|
|
361
|
-
pageContent = pageContent.replace(
|
|
386
|
+
`---\nsidebar_label: ${this._getSidebarLabelForApiItem(apiItem)}\n---` +
|
|
387
|
+
pageContent;
|
|
388
|
+
pageContent = pageContent.replace("##", "#");
|
|
389
|
+
pageContent = pageContent.replace(/<!-- -->/g, "");
|
|
390
|
+
pageContent = pageContent.replace(/<b>|<\/b>/g, "**");
|
|
362
391
|
FileSystem.writeFile(filename, pageContent, {
|
|
363
392
|
convertLineEndings: this._documenterConfig
|
|
364
393
|
? this._documenterConfig.newlineKind
|
|
@@ -366,54 +395,77 @@ export class MarkdownDocumenter {
|
|
|
366
395
|
});
|
|
367
396
|
}
|
|
368
397
|
|
|
369
|
-
private _writeHeritageTypes(
|
|
398
|
+
private _writeHeritageTypes(
|
|
399
|
+
output: DocSection,
|
|
400
|
+
apiItem: ApiDeclaredItem
|
|
401
|
+
): void {
|
|
370
402
|
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
|
371
403
|
|
|
372
404
|
if (apiItem instanceof ApiClass) {
|
|
373
405
|
if (apiItem.extendsType) {
|
|
374
|
-
const extendsParagraph: DocParagraph = new DocParagraph(
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
406
|
+
const extendsParagraph: DocParagraph = new DocParagraph(
|
|
407
|
+
{ configuration },
|
|
408
|
+
[
|
|
409
|
+
new DocEmphasisSpan({ configuration, bold: true }, [
|
|
410
|
+
new DocPlainText({ configuration, text: "Extends: " }),
|
|
411
|
+
]),
|
|
412
|
+
]
|
|
413
|
+
);
|
|
414
|
+
this._appendExcerptWithHyperlinks(
|
|
415
|
+
extendsParagraph,
|
|
416
|
+
apiItem.extendsType.excerpt
|
|
417
|
+
);
|
|
380
418
|
output.appendNode(extendsParagraph);
|
|
381
419
|
}
|
|
382
420
|
if (apiItem.implementsTypes.length > 0) {
|
|
383
|
-
const extendsParagraph: DocParagraph = new DocParagraph(
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
421
|
+
const extendsParagraph: DocParagraph = new DocParagraph(
|
|
422
|
+
{ configuration },
|
|
423
|
+
[
|
|
424
|
+
new DocEmphasisSpan({ configuration, bold: true }, [
|
|
425
|
+
new DocPlainText({ configuration, text: "Implements: " }),
|
|
426
|
+
]),
|
|
427
|
+
]
|
|
428
|
+
);
|
|
388
429
|
let needsComma = false;
|
|
389
430
|
for (const implementsType of apiItem.implementsTypes) {
|
|
390
431
|
if (needsComma) {
|
|
391
|
-
extendsParagraph.appendNode(
|
|
432
|
+
extendsParagraph.appendNode(
|
|
433
|
+
new DocPlainText({ configuration, text: ", " })
|
|
434
|
+
);
|
|
392
435
|
}
|
|
393
|
-
this._appendExcerptWithHyperlinks(
|
|
436
|
+
this._appendExcerptWithHyperlinks(
|
|
437
|
+
extendsParagraph,
|
|
438
|
+
implementsType.excerpt
|
|
439
|
+
);
|
|
394
440
|
needsComma = true;
|
|
395
441
|
}
|
|
396
442
|
output.appendNode(extendsParagraph);
|
|
397
443
|
}
|
|
398
444
|
}
|
|
399
445
|
|
|
400
|
-
if (apiItem instanceof ApiInterface) {
|
|
401
|
-
|
|
402
|
-
|
|
446
|
+
if (apiItem instanceof ApiInterface && apiItem.extendsTypes.length > 0) {
|
|
447
|
+
const extendsParagraph: DocParagraph = new DocParagraph(
|
|
448
|
+
{ configuration },
|
|
449
|
+
[
|
|
403
450
|
new DocEmphasisSpan({ configuration, bold: true }, [
|
|
404
|
-
new DocPlainText({ configuration, text:
|
|
451
|
+
new DocPlainText({ configuration, text: "Extends: " }),
|
|
405
452
|
]),
|
|
406
|
-
]
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
453
|
+
]
|
|
454
|
+
);
|
|
455
|
+
let needsComma = false;
|
|
456
|
+
for (const extendsType of apiItem.extendsTypes) {
|
|
457
|
+
if (needsComma) {
|
|
458
|
+
extendsParagraph.appendNode(
|
|
459
|
+
new DocPlainText({ configuration, text: ", " })
|
|
460
|
+
);
|
|
414
461
|
}
|
|
415
|
-
|
|
462
|
+
this._appendExcerptWithHyperlinks(
|
|
463
|
+
extendsParagraph,
|
|
464
|
+
extendsType.excerpt
|
|
465
|
+
);
|
|
466
|
+
needsComma = true;
|
|
416
467
|
}
|
|
468
|
+
output.appendNode(extendsParagraph);
|
|
417
469
|
}
|
|
418
470
|
|
|
419
471
|
if (apiItem instanceof ApiTypeAlias) {
|
|
@@ -421,16 +473,21 @@ export class MarkdownDocumenter {
|
|
|
421
473
|
return (
|
|
422
474
|
token.kind === ExcerptTokenKind.Reference &&
|
|
423
475
|
token.canonicalReference &&
|
|
424
|
-
this._apiModel.resolveDeclarationReference(
|
|
425
|
-
.
|
|
476
|
+
this._apiModel.resolveDeclarationReference(
|
|
477
|
+
token.canonicalReference,
|
|
478
|
+
undefined
|
|
479
|
+
).resolvedApiItem
|
|
426
480
|
);
|
|
427
481
|
});
|
|
428
482
|
if (refs.length > 0) {
|
|
429
|
-
const referencesParagraph: DocParagraph = new DocParagraph(
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
483
|
+
const referencesParagraph: DocParagraph = new DocParagraph(
|
|
484
|
+
{ configuration },
|
|
485
|
+
[
|
|
486
|
+
new DocEmphasisSpan({ configuration, bold: true }, [
|
|
487
|
+
new DocPlainText({ configuration, text: "References: " }),
|
|
488
|
+
]),
|
|
489
|
+
]
|
|
490
|
+
);
|
|
434
491
|
let needsComma = false;
|
|
435
492
|
const visited: Set<string> = new Set();
|
|
436
493
|
for (const ref of refs) {
|
|
@@ -440,7 +497,9 @@ export class MarkdownDocumenter {
|
|
|
440
497
|
visited.add(ref.text);
|
|
441
498
|
|
|
442
499
|
if (needsComma) {
|
|
443
|
-
referencesParagraph.appendNode(
|
|
500
|
+
referencesParagraph.appendNode(
|
|
501
|
+
new DocPlainText({ configuration, text: ", " })
|
|
502
|
+
);
|
|
444
503
|
}
|
|
445
504
|
|
|
446
505
|
this._appendExcerptTokenWithHyperlinks(referencesParagraph, ref);
|
|
@@ -461,20 +520,26 @@ export class MarkdownDocumenter {
|
|
|
461
520
|
output.appendNode(
|
|
462
521
|
new DocHeading({
|
|
463
522
|
configuration: this._tsdocConfiguration,
|
|
464
|
-
title:
|
|
523
|
+
title: "Remarks",
|
|
465
524
|
})
|
|
466
525
|
);
|
|
467
526
|
this._appendSection(output, tsdocComment.remarksBlock.content);
|
|
468
527
|
}
|
|
469
528
|
|
|
470
529
|
// Write the @example blocks
|
|
471
|
-
const exampleBlocks: DocBlock[] = tsdocComment.customBlocks.filter(
|
|
472
|
-
|
|
473
|
-
|
|
530
|
+
const exampleBlocks: DocBlock[] = tsdocComment.customBlocks.filter(
|
|
531
|
+
(x) => {
|
|
532
|
+
return (
|
|
533
|
+
x.blockTag.tagNameWithUpperCase ===
|
|
534
|
+
StandardTags.example.tagNameWithUpperCase
|
|
535
|
+
);
|
|
536
|
+
}
|
|
537
|
+
);
|
|
474
538
|
|
|
475
539
|
let exampleNumber = 1;
|
|
476
540
|
for (const exampleBlock of exampleBlocks) {
|
|
477
|
-
const heading: string =
|
|
541
|
+
const heading: string =
|
|
542
|
+
exampleBlocks.length > 1 ? `Example ${exampleNumber}` : "Example";
|
|
478
543
|
|
|
479
544
|
output.appendNode(
|
|
480
545
|
new DocHeading({
|
|
@@ -497,12 +562,17 @@ export class MarkdownDocumenter {
|
|
|
497
562
|
|
|
498
563
|
if (tsdocComment) {
|
|
499
564
|
// Write the @throws blocks
|
|
500
|
-
const throwsBlocks: DocBlock[] = tsdocComment.customBlocks.filter(
|
|
501
|
-
|
|
502
|
-
|
|
565
|
+
const throwsBlocks: DocBlock[] = tsdocComment.customBlocks.filter(
|
|
566
|
+
(x) => {
|
|
567
|
+
return (
|
|
568
|
+
x.blockTag.tagNameWithUpperCase ===
|
|
569
|
+
StandardTags.throws.tagNameWithUpperCase
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
);
|
|
503
573
|
|
|
504
574
|
if (throwsBlocks.length > 0) {
|
|
505
|
-
const heading =
|
|
575
|
+
const heading = "Exceptions";
|
|
506
576
|
output.appendNode(
|
|
507
577
|
new DocHeading({
|
|
508
578
|
configuration: this._tsdocConfiguration,
|
|
@@ -526,7 +596,7 @@ export class MarkdownDocumenter {
|
|
|
526
596
|
|
|
527
597
|
const packagesTable: DocTable = new DocTable({
|
|
528
598
|
configuration,
|
|
529
|
-
headerTitles: [
|
|
599
|
+
headerTitles: ["Package", "Description"],
|
|
530
600
|
});
|
|
531
601
|
|
|
532
602
|
for (const apiMember of apiModel.members) {
|
|
@@ -547,7 +617,7 @@ export class MarkdownDocumenter {
|
|
|
547
617
|
output.appendNode(
|
|
548
618
|
new DocHeading({
|
|
549
619
|
configuration: this._tsdocConfiguration,
|
|
550
|
-
title:
|
|
620
|
+
title: "Packages",
|
|
551
621
|
})
|
|
552
622
|
);
|
|
553
623
|
output.appendNode(packagesTable);
|
|
@@ -565,42 +635,42 @@ export class MarkdownDocumenter {
|
|
|
565
635
|
|
|
566
636
|
const classesTable: DocTable = new DocTable({
|
|
567
637
|
configuration,
|
|
568
|
-
headerTitles: [
|
|
638
|
+
headerTitles: ["Class", "Description"],
|
|
569
639
|
});
|
|
570
640
|
|
|
571
641
|
const enumerationsTable: DocTable = new DocTable({
|
|
572
642
|
configuration,
|
|
573
|
-
headerTitles: [
|
|
643
|
+
headerTitles: ["Enumeration", "Description"],
|
|
574
644
|
});
|
|
575
645
|
|
|
576
646
|
const functionsTable: DocTable = new DocTable({
|
|
577
647
|
configuration,
|
|
578
|
-
headerTitles: [
|
|
648
|
+
headerTitles: ["Function", "Description"],
|
|
579
649
|
});
|
|
580
650
|
|
|
581
651
|
const interfacesTable: DocTable = new DocTable({
|
|
582
652
|
configuration,
|
|
583
|
-
headerTitles: [
|
|
653
|
+
headerTitles: ["Interface", "Description"],
|
|
584
654
|
});
|
|
585
655
|
|
|
586
656
|
const namespacesTable: DocTable = new DocTable({
|
|
587
657
|
configuration,
|
|
588
|
-
headerTitles: [
|
|
658
|
+
headerTitles: ["Namespace", "Description"],
|
|
589
659
|
});
|
|
590
660
|
|
|
591
661
|
const variablesTable: DocTable = new DocTable({
|
|
592
662
|
configuration,
|
|
593
|
-
headerTitles: [
|
|
663
|
+
headerTitles: ["Variable", "Description"],
|
|
594
664
|
});
|
|
595
665
|
|
|
596
666
|
const typeAliasesTable: DocTable = new DocTable({
|
|
597
667
|
configuration,
|
|
598
|
-
headerTitles: [
|
|
668
|
+
headerTitles: ["Type Alias", "Description"],
|
|
599
669
|
});
|
|
600
670
|
|
|
601
|
-
const apiMembers:
|
|
671
|
+
const apiMembers: readonly ApiItem[] =
|
|
602
672
|
apiContainer.kind === ApiItemKind.Package
|
|
603
|
-
? (apiContainer as ApiPackage).entryPoints[0]
|
|
673
|
+
? (apiContainer as ApiPackage).entryPoints[0]?.members
|
|
604
674
|
: (apiContainer as ApiNamespace).members;
|
|
605
675
|
|
|
606
676
|
for (const apiMember of apiMembers) {
|
|
@@ -651,7 +721,7 @@ export class MarkdownDocumenter {
|
|
|
651
721
|
output.appendNode(
|
|
652
722
|
new DocHeading({
|
|
653
723
|
configuration: this._tsdocConfiguration,
|
|
654
|
-
title:
|
|
724
|
+
title: "Classes",
|
|
655
725
|
})
|
|
656
726
|
);
|
|
657
727
|
output.appendNode(classesTable);
|
|
@@ -661,7 +731,7 @@ export class MarkdownDocumenter {
|
|
|
661
731
|
output.appendNode(
|
|
662
732
|
new DocHeading({
|
|
663
733
|
configuration: this._tsdocConfiguration,
|
|
664
|
-
title:
|
|
734
|
+
title: "Enumerations",
|
|
665
735
|
})
|
|
666
736
|
);
|
|
667
737
|
output.appendNode(enumerationsTable);
|
|
@@ -670,7 +740,7 @@ export class MarkdownDocumenter {
|
|
|
670
740
|
output.appendNode(
|
|
671
741
|
new DocHeading({
|
|
672
742
|
configuration: this._tsdocConfiguration,
|
|
673
|
-
title:
|
|
743
|
+
title: "Functions",
|
|
674
744
|
})
|
|
675
745
|
);
|
|
676
746
|
output.appendNode(functionsTable);
|
|
@@ -680,7 +750,7 @@ export class MarkdownDocumenter {
|
|
|
680
750
|
output.appendNode(
|
|
681
751
|
new DocHeading({
|
|
682
752
|
configuration: this._tsdocConfiguration,
|
|
683
|
-
title:
|
|
753
|
+
title: "Interfaces",
|
|
684
754
|
})
|
|
685
755
|
);
|
|
686
756
|
output.appendNode(interfacesTable);
|
|
@@ -690,7 +760,7 @@ export class MarkdownDocumenter {
|
|
|
690
760
|
output.appendNode(
|
|
691
761
|
new DocHeading({
|
|
692
762
|
configuration: this._tsdocConfiguration,
|
|
693
|
-
title:
|
|
763
|
+
title: "Namespaces",
|
|
694
764
|
})
|
|
695
765
|
);
|
|
696
766
|
output.appendNode(namespacesTable);
|
|
@@ -700,7 +770,7 @@ export class MarkdownDocumenter {
|
|
|
700
770
|
output.appendNode(
|
|
701
771
|
new DocHeading({
|
|
702
772
|
configuration: this._tsdocConfiguration,
|
|
703
|
-
title:
|
|
773
|
+
title: "Variables",
|
|
704
774
|
})
|
|
705
775
|
);
|
|
706
776
|
output.appendNode(variablesTable);
|
|
@@ -710,7 +780,7 @@ export class MarkdownDocumenter {
|
|
|
710
780
|
output.appendNode(
|
|
711
781
|
new DocHeading({
|
|
712
782
|
configuration: this._tsdocConfiguration,
|
|
713
|
-
title:
|
|
783
|
+
title: "Type Aliases",
|
|
714
784
|
})
|
|
715
785
|
);
|
|
716
786
|
output.appendNode(typeAliasesTable);
|
|
@@ -725,22 +795,22 @@ export class MarkdownDocumenter {
|
|
|
725
795
|
|
|
726
796
|
const eventsTable: DocTable = new DocTable({
|
|
727
797
|
configuration,
|
|
728
|
-
headerTitles: [
|
|
798
|
+
headerTitles: ["Property", "Modifiers", "Type", "Description"],
|
|
729
799
|
});
|
|
730
800
|
|
|
731
801
|
const constructorsTable: DocTable = new DocTable({
|
|
732
802
|
configuration,
|
|
733
|
-
headerTitles: [
|
|
803
|
+
headerTitles: ["Constructor", "Modifiers", "Description"],
|
|
734
804
|
});
|
|
735
805
|
|
|
736
806
|
const propertiesTable: DocTable = new DocTable({
|
|
737
807
|
configuration,
|
|
738
|
-
headerTitles: [
|
|
808
|
+
headerTitles: ["Property", "Modifiers", "Type", "Description"],
|
|
739
809
|
});
|
|
740
810
|
|
|
741
811
|
const methodsTable: DocTable = new DocTable({
|
|
742
812
|
configuration,
|
|
743
|
-
headerTitles: [
|
|
813
|
+
headerTitles: ["Method", "Modifiers", "Description"],
|
|
744
814
|
});
|
|
745
815
|
|
|
746
816
|
for (const apiMember of apiClass.members) {
|
|
@@ -800,7 +870,7 @@ export class MarkdownDocumenter {
|
|
|
800
870
|
output.appendNode(
|
|
801
871
|
new DocHeading({
|
|
802
872
|
configuration: this._tsdocConfiguration,
|
|
803
|
-
title:
|
|
873
|
+
title: "Events",
|
|
804
874
|
})
|
|
805
875
|
);
|
|
806
876
|
output.appendNode(eventsTable);
|
|
@@ -810,7 +880,7 @@ export class MarkdownDocumenter {
|
|
|
810
880
|
output.appendNode(
|
|
811
881
|
new DocHeading({
|
|
812
882
|
configuration: this._tsdocConfiguration,
|
|
813
|
-
title:
|
|
883
|
+
title: "Constructors",
|
|
814
884
|
})
|
|
815
885
|
);
|
|
816
886
|
output.appendNode(constructorsTable);
|
|
@@ -820,7 +890,7 @@ export class MarkdownDocumenter {
|
|
|
820
890
|
output.appendNode(
|
|
821
891
|
new DocHeading({
|
|
822
892
|
configuration: this._tsdocConfiguration,
|
|
823
|
-
title:
|
|
893
|
+
title: "Properties",
|
|
824
894
|
})
|
|
825
895
|
);
|
|
826
896
|
output.appendNode(propertiesTable);
|
|
@@ -830,7 +900,7 @@ export class MarkdownDocumenter {
|
|
|
830
900
|
output.appendNode(
|
|
831
901
|
new DocHeading({
|
|
832
902
|
configuration: this._tsdocConfiguration,
|
|
833
|
-
title:
|
|
903
|
+
title: "Methods",
|
|
834
904
|
})
|
|
835
905
|
);
|
|
836
906
|
output.appendNode(methodsTable);
|
|
@@ -845,7 +915,7 @@ export class MarkdownDocumenter {
|
|
|
845
915
|
|
|
846
916
|
const enumMembersTable: DocTable = new DocTable({
|
|
847
917
|
configuration,
|
|
848
|
-
headerTitles: [
|
|
918
|
+
headerTitles: ["Member", "Value", "Description"],
|
|
849
919
|
});
|
|
850
920
|
|
|
851
921
|
for (const apiEnumMember of apiEnum.members) {
|
|
@@ -869,7 +939,7 @@ export class MarkdownDocumenter {
|
|
|
869
939
|
output.appendNode(
|
|
870
940
|
new DocHeading({
|
|
871
941
|
configuration: this._tsdocConfiguration,
|
|
872
|
-
title:
|
|
942
|
+
title: "Enumeration Members",
|
|
873
943
|
})
|
|
874
944
|
);
|
|
875
945
|
output.appendNode(enumMembersTable);
|
|
@@ -879,22 +949,25 @@ export class MarkdownDocumenter {
|
|
|
879
949
|
/**
|
|
880
950
|
* GENERATE PAGE: INTERFACE
|
|
881
951
|
*/
|
|
882
|
-
private _writeInterfaceTables(
|
|
952
|
+
private _writeInterfaceTables(
|
|
953
|
+
output: DocSection,
|
|
954
|
+
apiClass: ApiInterface
|
|
955
|
+
): void {
|
|
883
956
|
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
|
884
957
|
|
|
885
958
|
const eventsTable: DocTable = new DocTable({
|
|
886
959
|
configuration,
|
|
887
|
-
headerTitles: [
|
|
960
|
+
headerTitles: ["Property", "Modifiers", "Type", "Description"],
|
|
888
961
|
});
|
|
889
962
|
|
|
890
963
|
const propertiesTable: DocTable = new DocTable({
|
|
891
964
|
configuration,
|
|
892
|
-
headerTitles: [
|
|
965
|
+
headerTitles: ["Property", "Modifiers", "Type", "Description"],
|
|
893
966
|
});
|
|
894
967
|
|
|
895
968
|
const methodsTable: DocTable = new DocTable({
|
|
896
969
|
configuration,
|
|
897
|
-
headerTitles: [
|
|
970
|
+
headerTitles: ["Method", "Description"],
|
|
898
971
|
});
|
|
899
972
|
|
|
900
973
|
for (const apiMember of apiClass.members) {
|
|
@@ -942,7 +1015,7 @@ export class MarkdownDocumenter {
|
|
|
942
1015
|
output.appendNode(
|
|
943
1016
|
new DocHeading({
|
|
944
1017
|
configuration: this._tsdocConfiguration,
|
|
945
|
-
title:
|
|
1018
|
+
title: "Events",
|
|
946
1019
|
})
|
|
947
1020
|
);
|
|
948
1021
|
output.appendNode(eventsTable);
|
|
@@ -952,7 +1025,7 @@ export class MarkdownDocumenter {
|
|
|
952
1025
|
output.appendNode(
|
|
953
1026
|
new DocHeading({
|
|
954
1027
|
configuration: this._tsdocConfiguration,
|
|
955
|
-
title:
|
|
1028
|
+
title: "Properties",
|
|
956
1029
|
})
|
|
957
1030
|
);
|
|
958
1031
|
output.appendNode(propertiesTable);
|
|
@@ -962,7 +1035,7 @@ export class MarkdownDocumenter {
|
|
|
962
1035
|
output.appendNode(
|
|
963
1036
|
new DocHeading({
|
|
964
1037
|
configuration: this._tsdocConfiguration,
|
|
965
|
-
title:
|
|
1038
|
+
title: "Methods",
|
|
966
1039
|
})
|
|
967
1040
|
);
|
|
968
1041
|
output.appendNode(methodsTable);
|
|
@@ -980,22 +1053,27 @@ export class MarkdownDocumenter {
|
|
|
980
1053
|
|
|
981
1054
|
const parametersTable: DocTable = new DocTable({
|
|
982
1055
|
configuration,
|
|
983
|
-
headerTitles: [
|
|
1056
|
+
headerTitles: ["Parameter", "Type", "Description"],
|
|
984
1057
|
});
|
|
985
1058
|
for (const apiParameter of apiParameterListMixin.parameters) {
|
|
986
|
-
const parameterDescription: DocSection = new DocSection({
|
|
1059
|
+
const parameterDescription: DocSection = new DocSection({
|
|
1060
|
+
configuration,
|
|
1061
|
+
});
|
|
987
1062
|
|
|
988
1063
|
if (apiParameter.isOptional) {
|
|
989
1064
|
parameterDescription.appendNodesInParagraph([
|
|
990
1065
|
new DocEmphasisSpan({ configuration, italic: true }, [
|
|
991
|
-
new DocPlainText({ configuration, text:
|
|
1066
|
+
new DocPlainText({ configuration, text: "(Optional)" }),
|
|
992
1067
|
]),
|
|
993
|
-
new DocPlainText({ configuration, text:
|
|
1068
|
+
new DocPlainText({ configuration, text: " " }),
|
|
994
1069
|
]);
|
|
995
1070
|
}
|
|
996
1071
|
|
|
997
1072
|
if (apiParameter.tsdocParamBlock) {
|
|
998
|
-
this._appendAndMergeSection(
|
|
1073
|
+
this._appendAndMergeSection(
|
|
1074
|
+
parameterDescription,
|
|
1075
|
+
apiParameter.tsdocParamBlock.content
|
|
1076
|
+
);
|
|
999
1077
|
}
|
|
1000
1078
|
|
|
1001
1079
|
parametersTable.addRow(
|
|
@@ -1006,7 +1084,9 @@ export class MarkdownDocumenter {
|
|
|
1006
1084
|
]),
|
|
1007
1085
|
]),
|
|
1008
1086
|
new DocTableCell({ configuration }, [
|
|
1009
|
-
this._createParagraphForTypeExcerpt(
|
|
1087
|
+
this._createParagraphForTypeExcerpt(
|
|
1088
|
+
apiParameter.parameterTypeExcerpt
|
|
1089
|
+
),
|
|
1010
1090
|
]),
|
|
1011
1091
|
new DocTableCell({ configuration }, parameterDescription.nodes),
|
|
1012
1092
|
])
|
|
@@ -1017,28 +1097,34 @@ export class MarkdownDocumenter {
|
|
|
1017
1097
|
output.appendNode(
|
|
1018
1098
|
new DocHeading({
|
|
1019
1099
|
configuration: this._tsdocConfiguration,
|
|
1020
|
-
title:
|
|
1100
|
+
title: "Parameters",
|
|
1021
1101
|
})
|
|
1022
1102
|
);
|
|
1023
1103
|
output.appendNode(parametersTable);
|
|
1024
1104
|
}
|
|
1025
1105
|
|
|
1026
1106
|
if (ApiReturnTypeMixin.isBaseClassOf(apiParameterListMixin)) {
|
|
1027
|
-
const returnTypeExcerpt: Excerpt =
|
|
1107
|
+
const returnTypeExcerpt: Excerpt =
|
|
1108
|
+
apiParameterListMixin.returnTypeExcerpt;
|
|
1028
1109
|
output.appendNode(
|
|
1029
1110
|
new DocParagraph({ configuration }, [
|
|
1030
1111
|
new DocEmphasisSpan({ configuration, bold: true }, [
|
|
1031
|
-
new DocPlainText({ configuration, text:
|
|
1112
|
+
new DocPlainText({ configuration, text: "Returns:" }),
|
|
1032
1113
|
]),
|
|
1033
1114
|
])
|
|
1034
1115
|
);
|
|
1035
1116
|
|
|
1036
1117
|
output.appendNode(this._createParagraphForTypeExcerpt(returnTypeExcerpt));
|
|
1037
1118
|
|
|
1038
|
-
if (
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1119
|
+
if (
|
|
1120
|
+
apiParameterListMixin instanceof ApiDocumentedItem &&
|
|
1121
|
+
apiParameterListMixin.tsdocComment &&
|
|
1122
|
+
apiParameterListMixin.tsdocComment.returnsBlock
|
|
1123
|
+
) {
|
|
1124
|
+
this._appendSection(
|
|
1125
|
+
output,
|
|
1126
|
+
apiParameterListMixin.tsdocComment.returnsBlock.content
|
|
1127
|
+
);
|
|
1042
1128
|
}
|
|
1043
1129
|
}
|
|
1044
1130
|
}
|
|
@@ -1047,16 +1133,21 @@ export class MarkdownDocumenter {
|
|
|
1047
1133
|
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
|
1048
1134
|
|
|
1049
1135
|
const paragraph: DocParagraph = new DocParagraph({ configuration });
|
|
1050
|
-
if (
|
|
1051
|
-
paragraph.appendNode(new DocPlainText({ configuration, text: '(not declared)' }));
|
|
1052
|
-
} else {
|
|
1136
|
+
if (excerpt.text.trim()) {
|
|
1053
1137
|
this._appendExcerptWithHyperlinks(paragraph, excerpt);
|
|
1138
|
+
} else {
|
|
1139
|
+
paragraph.appendNode(
|
|
1140
|
+
new DocPlainText({ configuration, text: "(not declared)" })
|
|
1141
|
+
);
|
|
1054
1142
|
}
|
|
1055
1143
|
|
|
1056
1144
|
return paragraph;
|
|
1057
1145
|
}
|
|
1058
1146
|
|
|
1059
|
-
private _appendExcerptWithHyperlinks(
|
|
1147
|
+
private _appendExcerptWithHyperlinks(
|
|
1148
|
+
docNodeContainer: DocNodeContainer,
|
|
1149
|
+
excerpt: Excerpt
|
|
1150
|
+
): void {
|
|
1060
1151
|
for (const token of excerpt.spannedTokens) {
|
|
1061
1152
|
this._appendExcerptTokenWithHyperlinks(docNodeContainer, token);
|
|
1062
1153
|
}
|
|
@@ -1072,20 +1163,25 @@ export class MarkdownDocumenter {
|
|
|
1072
1163
|
// spans, so we will render the type expression as DocPlainText. Instead of
|
|
1073
1164
|
// creating multiple DocParagraphs, we can simply discard any newlines and
|
|
1074
1165
|
// let the renderer do normal word-wrapping.
|
|
1075
|
-
const unwrappedTokenText: string = token.text.replace(/[\r\n]+/g,
|
|
1166
|
+
const unwrappedTokenText: string = token.text.replace(/[\r\n]+/g, " ");
|
|
1076
1167
|
|
|
1077
1168
|
// If it's hyperlinkable, then append a DocLinkTag
|
|
1078
1169
|
if (token.kind === ExcerptTokenKind.Reference && token.canonicalReference) {
|
|
1079
1170
|
const apiItemResult: IResolveDeclarationReferenceResult =
|
|
1080
|
-
this._apiModel.resolveDeclarationReference(
|
|
1171
|
+
this._apiModel.resolveDeclarationReference(
|
|
1172
|
+
token.canonicalReference,
|
|
1173
|
+
undefined
|
|
1174
|
+
);
|
|
1081
1175
|
|
|
1082
1176
|
if (apiItemResult.resolvedApiItem) {
|
|
1083
1177
|
docNodeContainer.appendNode(
|
|
1084
1178
|
new DocLinkTag({
|
|
1085
1179
|
configuration,
|
|
1086
|
-
tagName:
|
|
1180
|
+
tagName: "@link",
|
|
1087
1181
|
linkText: unwrappedTokenText,
|
|
1088
|
-
urlDestination: this._getLinkFilenameForApiItem(
|
|
1182
|
+
urlDestination: this._getLinkFilenameForApiItem(
|
|
1183
|
+
apiItemResult.resolvedApiItem
|
|
1184
|
+
),
|
|
1089
1185
|
})
|
|
1090
1186
|
);
|
|
1091
1187
|
return;
|
|
@@ -1093,7 +1189,9 @@ export class MarkdownDocumenter {
|
|
|
1093
1189
|
}
|
|
1094
1190
|
|
|
1095
1191
|
// Otherwise append non-hyperlinked text
|
|
1096
|
-
docNodeContainer.appendNode(
|
|
1192
|
+
docNodeContainer.appendNode(
|
|
1193
|
+
new DocPlainText({ configuration, text: unwrappedTokenText })
|
|
1194
|
+
);
|
|
1097
1195
|
}
|
|
1098
1196
|
|
|
1099
1197
|
private _createTitleCell(apiItem: ApiItem): DocTableCell {
|
|
@@ -1101,15 +1199,15 @@ export class MarkdownDocumenter {
|
|
|
1101
1199
|
|
|
1102
1200
|
let linkText: string = Utilities.getConciseSignature(apiItem);
|
|
1103
1201
|
if (ApiOptionalMixin.isBaseClassOf(apiItem) && apiItem.isOptional) {
|
|
1104
|
-
linkText +=
|
|
1202
|
+
linkText += "?";
|
|
1105
1203
|
}
|
|
1106
1204
|
|
|
1107
1205
|
return new DocTableCell({ configuration }, [
|
|
1108
1206
|
new DocParagraph({ configuration }, [
|
|
1109
1207
|
new DocLinkTag({
|
|
1110
1208
|
configuration,
|
|
1111
|
-
tagName:
|
|
1112
|
-
linkText
|
|
1209
|
+
tagName: "@link",
|
|
1210
|
+
linkText,
|
|
1113
1211
|
urlDestination: this._getLinkFilenameForApiItem(apiItem),
|
|
1114
1212
|
}),
|
|
1115
1213
|
]),
|
|
@@ -1130,30 +1228,32 @@ export class MarkdownDocumenter {
|
|
|
1130
1228
|
|
|
1131
1229
|
const section: DocSection = new DocSection({ configuration });
|
|
1132
1230
|
|
|
1133
|
-
if (
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
new DocPlainText({ configuration, text:
|
|
1140
|
-
])
|
|
1141
|
-
|
|
1231
|
+
if (
|
|
1232
|
+
ApiReleaseTagMixin.isBaseClassOf(apiItem) &&
|
|
1233
|
+
apiItem.releaseTag === ReleaseTag.Beta
|
|
1234
|
+
) {
|
|
1235
|
+
section.appendNodesInParagraph([
|
|
1236
|
+
new DocEmphasisSpan({ configuration, bold: true, italic: true }, [
|
|
1237
|
+
new DocPlainText({ configuration, text: "(BETA)" }),
|
|
1238
|
+
]),
|
|
1239
|
+
new DocPlainText({ configuration, text: " " }),
|
|
1240
|
+
]);
|
|
1142
1241
|
}
|
|
1143
1242
|
|
|
1144
1243
|
if (ApiOptionalMixin.isBaseClassOf(apiItem) && apiItem.isOptional) {
|
|
1145
1244
|
section.appendNodesInParagraph([
|
|
1146
1245
|
new DocEmphasisSpan({ configuration, italic: true }, [
|
|
1147
|
-
new DocPlainText({ configuration, text:
|
|
1246
|
+
new DocPlainText({ configuration, text: "(Optional)" }),
|
|
1148
1247
|
]),
|
|
1149
|
-
new DocPlainText({ configuration, text:
|
|
1248
|
+
new DocPlainText({ configuration, text: " " }),
|
|
1150
1249
|
]);
|
|
1151
1250
|
}
|
|
1152
1251
|
|
|
1153
|
-
if (
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1252
|
+
if (
|
|
1253
|
+
apiItem instanceof ApiDocumentedItem &&
|
|
1254
|
+
apiItem.tsdocComment !== undefined
|
|
1255
|
+
) {
|
|
1256
|
+
this._appendAndMergeSection(section, apiItem.tsdocComment.summarySection);
|
|
1157
1257
|
}
|
|
1158
1258
|
|
|
1159
1259
|
return new DocTableCell({ configuration }, section.nodes);
|
|
@@ -1164,32 +1264,28 @@ export class MarkdownDocumenter {
|
|
|
1164
1264
|
|
|
1165
1265
|
const section: DocSection = new DocSection({ configuration });
|
|
1166
1266
|
|
|
1167
|
-
if (ApiProtectedMixin.isBaseClassOf(apiItem)) {
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
new
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
);
|
|
1174
|
-
}
|
|
1267
|
+
if (ApiProtectedMixin.isBaseClassOf(apiItem) && apiItem.isProtected) {
|
|
1268
|
+
section.appendNode(
|
|
1269
|
+
new DocParagraph({ configuration }, [
|
|
1270
|
+
new DocCodeSpan({ configuration, code: "protected" }),
|
|
1271
|
+
])
|
|
1272
|
+
);
|
|
1175
1273
|
}
|
|
1176
1274
|
|
|
1177
|
-
if (ApiReadonlyMixin.isBaseClassOf(apiItem)) {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
new
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
);
|
|
1184
|
-
}
|
|
1275
|
+
if (ApiReadonlyMixin.isBaseClassOf(apiItem) && apiItem.isReadonly) {
|
|
1276
|
+
section.appendNode(
|
|
1277
|
+
new DocParagraph({ configuration }, [
|
|
1278
|
+
new DocCodeSpan({ configuration, code: "readonly" }),
|
|
1279
|
+
])
|
|
1280
|
+
);
|
|
1185
1281
|
}
|
|
1186
1282
|
|
|
1187
|
-
if (ApiStaticMixin.isBaseClassOf(apiItem)) {
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
new
|
|
1191
|
-
)
|
|
1192
|
-
|
|
1283
|
+
if (ApiStaticMixin.isBaseClassOf(apiItem) && apiItem.isStatic) {
|
|
1284
|
+
section.appendNode(
|
|
1285
|
+
new DocParagraph({ configuration }, [
|
|
1286
|
+
new DocCodeSpan({ configuration, code: "static" }),
|
|
1287
|
+
])
|
|
1288
|
+
);
|
|
1193
1289
|
}
|
|
1194
1290
|
|
|
1195
1291
|
return new DocTableCell({ configuration }, section.nodes);
|
|
@@ -1201,7 +1297,9 @@ export class MarkdownDocumenter {
|
|
|
1201
1297
|
const section: DocSection = new DocSection({ configuration });
|
|
1202
1298
|
|
|
1203
1299
|
if (apiItem instanceof ApiPropertyItem) {
|
|
1204
|
-
section.appendNode(
|
|
1300
|
+
section.appendNode(
|
|
1301
|
+
this._createParagraphForTypeExcerpt(apiItem.propertyTypeExcerpt)
|
|
1302
|
+
);
|
|
1205
1303
|
}
|
|
1206
1304
|
|
|
1207
1305
|
return new DocTableCell({ configuration }, section.nodes);
|
|
@@ -1212,15 +1310,16 @@ export class MarkdownDocumenter {
|
|
|
1212
1310
|
|
|
1213
1311
|
const section: DocSection = new DocSection({ configuration });
|
|
1214
1312
|
|
|
1215
|
-
if (
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1313
|
+
if (
|
|
1314
|
+
ApiInitializerMixin.isBaseClassOf(apiItem) &&
|
|
1315
|
+
apiItem.initializerExcerpt
|
|
1316
|
+
) {
|
|
1317
|
+
section.appendNodeInParagraph(
|
|
1318
|
+
new DocCodeSpan({
|
|
1319
|
+
configuration,
|
|
1320
|
+
code: apiItem.initializerExcerpt.text,
|
|
1321
|
+
})
|
|
1322
|
+
);
|
|
1224
1323
|
}
|
|
1225
1324
|
|
|
1226
1325
|
return new DocTableCell({ configuration }, section.nodes);
|
|
@@ -1229,8 +1328,8 @@ export class MarkdownDocumenter {
|
|
|
1229
1328
|
private _writeBetaWarning(output: DocSection): void {
|
|
1230
1329
|
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
|
1231
1330
|
const betaWarning: string =
|
|
1232
|
-
|
|
1233
|
-
|
|
1331
|
+
"This API is provided as a preview for developers and may change" +
|
|
1332
|
+
" based on feedback that we receive. Do not use this API in a production environment.";
|
|
1234
1333
|
output.appendNode(
|
|
1235
1334
|
new DocNoteBox({ configuration }, [
|
|
1236
1335
|
new DocParagraph({ configuration }, [
|
|
@@ -1246,15 +1345,16 @@ export class MarkdownDocumenter {
|
|
|
1246
1345
|
}
|
|
1247
1346
|
}
|
|
1248
1347
|
|
|
1249
|
-
private _appendAndMergeSection(
|
|
1348
|
+
private _appendAndMergeSection(
|
|
1349
|
+
output: DocSection,
|
|
1350
|
+
docSection: DocSection
|
|
1351
|
+
): void {
|
|
1250
1352
|
let firstNode = true;
|
|
1251
1353
|
for (const node of docSection.nodes) {
|
|
1252
|
-
if (firstNode) {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
continue;
|
|
1257
|
-
}
|
|
1354
|
+
if (firstNode && node.kind === DocNodeKind.Paragraph) {
|
|
1355
|
+
output.appendNodesInParagraph(node.getChildNodes());
|
|
1356
|
+
firstNode = false;
|
|
1357
|
+
continue;
|
|
1258
1358
|
}
|
|
1259
1359
|
firstNode = false;
|
|
1260
1360
|
|
|
@@ -1264,19 +1364,20 @@ export class MarkdownDocumenter {
|
|
|
1264
1364
|
|
|
1265
1365
|
private _getSidebarLabelForApiItem(apiItem: ApiItem): string {
|
|
1266
1366
|
if (apiItem.kind === ApiItemKind.Package) {
|
|
1267
|
-
return
|
|
1367
|
+
return "API";
|
|
1268
1368
|
}
|
|
1269
1369
|
|
|
1270
|
-
let baseName =
|
|
1370
|
+
let baseName = "";
|
|
1271
1371
|
for (const hierarchyItem of apiItem.getHierarchy()) {
|
|
1272
1372
|
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
|
|
1273
1373
|
let qualifiedName: string = hierarchyItem.displayName;
|
|
1274
|
-
if (
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1374
|
+
if (
|
|
1375
|
+
ApiParameterListMixin.isBaseClassOf(hierarchyItem) &&
|
|
1376
|
+
hierarchyItem.overloadIndex > 1
|
|
1377
|
+
) {
|
|
1378
|
+
// Subtract one for compatibility with earlier releases of API Documenter.
|
|
1379
|
+
// (This will get revamped when we fix GitHub issue #1308)
|
|
1380
|
+
qualifiedName += `_${hierarchyItem.overloadIndex - 1}`;
|
|
1280
1381
|
}
|
|
1281
1382
|
|
|
1282
1383
|
switch (hierarchyItem.kind) {
|
|
@@ -1286,7 +1387,7 @@ export class MarkdownDocumenter {
|
|
|
1286
1387
|
case ApiItemKind.Package:
|
|
1287
1388
|
break;
|
|
1288
1389
|
default:
|
|
1289
|
-
baseName += qualifiedName
|
|
1390
|
+
baseName += `${qualifiedName}.`;
|
|
1290
1391
|
}
|
|
1291
1392
|
}
|
|
1292
1393
|
return baseName.slice(0, baseName.length - 1);
|
|
@@ -1294,19 +1395,22 @@ export class MarkdownDocumenter {
|
|
|
1294
1395
|
|
|
1295
1396
|
private _getFilenameForApiItem(apiItem: ApiItem): string {
|
|
1296
1397
|
if (apiItem.kind === ApiItemKind.Package) {
|
|
1297
|
-
return
|
|
1398
|
+
return "index.md";
|
|
1298
1399
|
}
|
|
1299
1400
|
|
|
1300
|
-
let baseName =
|
|
1401
|
+
let baseName = "";
|
|
1301
1402
|
for (const hierarchyItem of apiItem.getHierarchy()) {
|
|
1302
1403
|
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
|
|
1303
|
-
let qualifiedName: string = Utilities.getSafeFilenameForName(
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1404
|
+
let qualifiedName: string = Utilities.getSafeFilenameForName(
|
|
1405
|
+
hierarchyItem.displayName
|
|
1406
|
+
);
|
|
1407
|
+
if (
|
|
1408
|
+
ApiParameterListMixin.isBaseClassOf(hierarchyItem) &&
|
|
1409
|
+
hierarchyItem.overloadIndex > 1
|
|
1410
|
+
) {
|
|
1411
|
+
// Subtract one for compatibility with earlier releases of API Documenter.
|
|
1412
|
+
// (This will get revamped when we fix GitHub issue #1308)
|
|
1413
|
+
qualifiedName += `_${hierarchyItem.overloadIndex - 1}`;
|
|
1310
1414
|
}
|
|
1311
1415
|
|
|
1312
1416
|
switch (hierarchyItem.kind) {
|
|
@@ -1320,18 +1424,18 @@ export class MarkdownDocumenter {
|
|
|
1320
1424
|
);
|
|
1321
1425
|
break;
|
|
1322
1426
|
default:
|
|
1323
|
-
baseName +=
|
|
1427
|
+
baseName += `.${qualifiedName}`;
|
|
1324
1428
|
}
|
|
1325
1429
|
}
|
|
1326
|
-
return baseName
|
|
1430
|
+
return `${baseName}.md`;
|
|
1327
1431
|
}
|
|
1328
1432
|
|
|
1329
1433
|
private _getLinkFilenameForApiItem(apiItem: ApiItem): string {
|
|
1330
|
-
return
|
|
1434
|
+
return `./${this._getFilenameForApiItem(apiItem)}`;
|
|
1331
1435
|
}
|
|
1332
1436
|
|
|
1333
1437
|
private _deleteOldOutputFiles(): void {
|
|
1334
|
-
console.log(
|
|
1438
|
+
console.log(`Deleting old output from ${this._outputFolder}`);
|
|
1335
1439
|
FileSystem.ensureEmptyFolder(this._outputFolder);
|
|
1336
1440
|
}
|
|
1337
1441
|
}
|