mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: let TypeScript infer type (#12256)
This commit is contained in:
parent
75f170b26d
commit
958fce0fba
@ -88,7 +88,7 @@ export interface IMarkdownDocumenterOptions {
|
|||||||
|
|
||||||
export class CustomMarkdownEmitter extends ApiFormatterMarkdownEmitter {
|
export class CustomMarkdownEmitter extends ApiFormatterMarkdownEmitter {
|
||||||
protected override getEscapedText(text: string): string {
|
protected override getEscapedText(text: string): string {
|
||||||
const textWithBackslashes: string = text
|
const textWithBackslashes = text
|
||||||
.replace(/\\/g, '\\\\') // first replace the escape character
|
.replace(/\\/g, '\\\\') // first replace the escape character
|
||||||
.replace(/[*#[\]_|`~]/g, x => {
|
.replace(/[*#[\]_|`~]/g, x => {
|
||||||
return '\\' + x;
|
return '\\' + x;
|
||||||
@ -150,12 +150,12 @@ export class MarkdownDocumenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _writeApiItemPage(apiItem: ApiItem): void {
|
private _writeApiItemPage(apiItem: ApiItem): void {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
const output: DocSection = new DocSection({
|
const output = new DocSection({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
});
|
});
|
||||||
|
|
||||||
const scopedName: string = apiItem.getScopedNameWithinPackage();
|
const scopedName = apiItem.getScopedNameWithinPackage();
|
||||||
|
|
||||||
switch (apiItem.kind) {
|
switch (apiItem.kind) {
|
||||||
case ApiItemKind.Class:
|
case ApiItemKind.Class:
|
||||||
@ -253,7 +253,7 @@ export class MarkdownDocumenter {
|
|||||||
new DocNoteBox({configuration: this._tsdocConfiguration}, [
|
new DocNoteBox({configuration: this._tsdocConfiguration}, [
|
||||||
new DocParagraph({configuration: this._tsdocConfiguration}, [
|
new DocParagraph({configuration: this._tsdocConfiguration}, [
|
||||||
new DocPlainText({
|
new DocPlainText({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
text: 'Warning: This API is now obsolete. ',
|
text: 'Warning: This API is now obsolete. ',
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
@ -363,11 +363,11 @@ export class MarkdownDocumenter {
|
|||||||
this._writeRemarksSection(output, apiItem);
|
this._writeRemarksSection(output, apiItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
const filename: string = path.join(
|
const filename = path.join(
|
||||||
this._outputFolder,
|
this._outputFolder,
|
||||||
this._getFilenameForApiItem(apiItem)
|
this._getFilenameForApiItem(apiItem)
|
||||||
);
|
);
|
||||||
const stringBuilder: StringBuilder = new StringBuilder();
|
const stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
this._markdownEmitter.emit(stringBuilder, output, {
|
this._markdownEmitter.emit(stringBuilder, output, {
|
||||||
contextApiItem: apiItem,
|
contextApiItem: apiItem,
|
||||||
@ -376,7 +376,7 @@ export class MarkdownDocumenter {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let pageContent: string = stringBuilder.toString();
|
let pageContent = stringBuilder.toString();
|
||||||
|
|
||||||
if (this._pluginLoader.markdownDocumenterFeature) {
|
if (this._pluginLoader.markdownDocumenterFeature) {
|
||||||
// Allow the plugin to customize the pageContent
|
// Allow the plugin to customize the pageContent
|
||||||
@ -407,18 +407,15 @@ export class MarkdownDocumenter {
|
|||||||
output: DocSection,
|
output: DocSection,
|
||||||
apiItem: ApiDeclaredItem
|
apiItem: ApiDeclaredItem
|
||||||
): void {
|
): void {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
if (apiItem instanceof ApiClass) {
|
if (apiItem instanceof ApiClass) {
|
||||||
if (apiItem.extendsType) {
|
if (apiItem.extendsType) {
|
||||||
const extendsParagraph: DocParagraph = new DocParagraph(
|
const extendsParagraph = new DocParagraph({configuration}, [
|
||||||
{configuration},
|
new DocEmphasisSpan({configuration, bold: true}, [
|
||||||
[
|
new DocPlainText({configuration, text: 'Extends: '}),
|
||||||
new DocEmphasisSpan({configuration, bold: true}, [
|
]),
|
||||||
new DocPlainText({configuration, text: 'Extends: '}),
|
]);
|
||||||
]),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
this._appendExcerptWithHyperlinks(
|
this._appendExcerptWithHyperlinks(
|
||||||
extendsParagraph,
|
extendsParagraph,
|
||||||
apiItem.extendsType.excerpt
|
apiItem.extendsType.excerpt
|
||||||
@ -426,14 +423,11 @@ export class MarkdownDocumenter {
|
|||||||
output.appendNode(extendsParagraph);
|
output.appendNode(extendsParagraph);
|
||||||
}
|
}
|
||||||
if (apiItem.implementsTypes.length > 0) {
|
if (apiItem.implementsTypes.length > 0) {
|
||||||
const extendsParagraph: DocParagraph = new DocParagraph(
|
const extendsParagraph = new DocParagraph({configuration}, [
|
||||||
{configuration},
|
new DocEmphasisSpan({configuration, bold: true}, [
|
||||||
[
|
new DocPlainText({configuration, text: 'Implements: '}),
|
||||||
new DocEmphasisSpan({configuration, bold: true}, [
|
]),
|
||||||
new DocPlainText({configuration, text: 'Implements: '}),
|
]);
|
||||||
]),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
let needsComma = false;
|
let needsComma = false;
|
||||||
for (const implementsType of apiItem.implementsTypes) {
|
for (const implementsType of apiItem.implementsTypes) {
|
||||||
if (needsComma) {
|
if (needsComma) {
|
||||||
@ -453,14 +447,11 @@ export class MarkdownDocumenter {
|
|||||||
|
|
||||||
if (apiItem instanceof ApiInterface) {
|
if (apiItem instanceof ApiInterface) {
|
||||||
if (apiItem.extendsTypes.length > 0) {
|
if (apiItem.extendsTypes.length > 0) {
|
||||||
const extendsParagraph: DocParagraph = new DocParagraph(
|
const extendsParagraph = new DocParagraph({configuration}, [
|
||||||
{configuration},
|
new DocEmphasisSpan({configuration, bold: true}, [
|
||||||
[
|
new DocPlainText({configuration, text: 'Extends: '}),
|
||||||
new DocEmphasisSpan({configuration, bold: true}, [
|
]),
|
||||||
new DocPlainText({configuration, text: 'Extends: '}),
|
]);
|
||||||
]),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
let needsComma = false;
|
let needsComma = false;
|
||||||
for (const extendsType of apiItem.extendsTypes) {
|
for (const extendsType of apiItem.extendsTypes) {
|
||||||
if (needsComma) {
|
if (needsComma) {
|
||||||
@ -490,14 +481,11 @@ export class MarkdownDocumenter {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
if (refs.length > 0) {
|
if (refs.length > 0) {
|
||||||
const referencesParagraph: DocParagraph = new DocParagraph(
|
const referencesParagraph = new DocParagraph({configuration}, [
|
||||||
{configuration},
|
new DocEmphasisSpan({configuration, bold: true}, [
|
||||||
[
|
new DocPlainText({configuration, text: 'References: '}),
|
||||||
new DocEmphasisSpan({configuration, bold: true}, [
|
]),
|
||||||
new DocPlainText({configuration, text: 'References: '}),
|
]);
|
||||||
]),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
let needsComma = false;
|
let needsComma = false;
|
||||||
const visited = new Set<string>();
|
const visited = new Set<string>();
|
||||||
for (const ref of refs) {
|
for (const ref of refs) {
|
||||||
@ -542,6 +530,8 @@ export class MarkdownDocumenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _writeRemarksSection(output: DocSection, apiItem: ApiItem): void {
|
private _writeRemarksSection(output: DocSection, apiItem: ApiItem): void {
|
||||||
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
if (apiItem instanceof ApiDocumentedItem) {
|
if (apiItem instanceof ApiDocumentedItem) {
|
||||||
const tsdocComment: DocComment | undefined = apiItem.tsdocComment;
|
const tsdocComment: DocComment | undefined = apiItem.tsdocComment;
|
||||||
|
|
||||||
@ -550,7 +540,7 @@ export class MarkdownDocumenter {
|
|||||||
if (tsdocComment.remarksBlock) {
|
if (tsdocComment.remarksBlock) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Remarks',
|
title: 'Remarks',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -574,7 +564,7 @@ export class MarkdownDocumenter {
|
|||||||
|
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: heading,
|
title: heading,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -621,15 +611,15 @@ export class MarkdownDocumenter {
|
|||||||
* GENERATE PAGE: MODEL
|
* GENERATE PAGE: MODEL
|
||||||
*/
|
*/
|
||||||
private _writeModelTable(output: DocSection, apiModel: ApiModel): void {
|
private _writeModelTable(output: DocSection, apiModel: ApiModel): void {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const packagesTable: DocTable = new DocTable({
|
const packagesTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Package', 'Description'],
|
headerTitles: ['Package', 'Description'],
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const apiMember of apiModel.members) {
|
for (const apiMember of apiModel.members) {
|
||||||
const row: DocTableRow = new DocTableRow({configuration}, [
|
const row = new DocTableRow({configuration}, [
|
||||||
this._createTitleCell(apiMember),
|
this._createTitleCell(apiMember),
|
||||||
this._createDescriptionCell(apiMember),
|
this._createDescriptionCell(apiMember),
|
||||||
]);
|
]);
|
||||||
@ -645,7 +635,7 @@ export class MarkdownDocumenter {
|
|||||||
if (packagesTable.rows.length > 0) {
|
if (packagesTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Packages',
|
title: 'Packages',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -660,39 +650,39 @@ export class MarkdownDocumenter {
|
|||||||
output: DocSection,
|
output: DocSection,
|
||||||
apiContainer: ApiPackage | ApiNamespace
|
apiContainer: ApiPackage | ApiNamespace
|
||||||
): void {
|
): void {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const classesTable: DocTable = new DocTable({
|
const classesTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Class', 'Description'],
|
headerTitles: ['Class', 'Description'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const enumerationsTable: DocTable = new DocTable({
|
const enumerationsTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Enumeration', 'Description'],
|
headerTitles: ['Enumeration', 'Description'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const functionsTable: DocTable = new DocTable({
|
const functionsTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Function', 'Description'],
|
headerTitles: ['Function', 'Description'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const interfacesTable: DocTable = new DocTable({
|
const interfacesTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Interface', 'Description'],
|
headerTitles: ['Interface', 'Description'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const namespacesTable: DocTable = new DocTable({
|
const namespacesTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Namespace', 'Description'],
|
headerTitles: ['Namespace', 'Description'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const variablesTable: DocTable = new DocTable({
|
const variablesTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Variable', 'Description'],
|
headerTitles: ['Variable', 'Description'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const typeAliasesTable: DocTable = new DocTable({
|
const typeAliasesTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Type Alias', 'Description'],
|
headerTitles: ['Type Alias', 'Description'],
|
||||||
});
|
});
|
||||||
@ -703,7 +693,7 @@ export class MarkdownDocumenter {
|
|||||||
: (apiContainer as ApiNamespace).members;
|
: (apiContainer as ApiNamespace).members;
|
||||||
|
|
||||||
for (const apiMember of apiMembers) {
|
for (const apiMember of apiMembers) {
|
||||||
const row: DocTableRow = new DocTableRow({configuration}, [
|
const row = new DocTableRow({configuration}, [
|
||||||
this._createTitleCell(apiMember),
|
this._createTitleCell(apiMember),
|
||||||
this._createDescriptionCell(apiMember),
|
this._createDescriptionCell(apiMember),
|
||||||
]);
|
]);
|
||||||
@ -749,7 +739,7 @@ export class MarkdownDocumenter {
|
|||||||
if (classesTable.rows.length > 0) {
|
if (classesTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Classes',
|
title: 'Classes',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -759,7 +749,7 @@ export class MarkdownDocumenter {
|
|||||||
if (enumerationsTable.rows.length > 0) {
|
if (enumerationsTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Enumerations',
|
title: 'Enumerations',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -768,7 +758,7 @@ export class MarkdownDocumenter {
|
|||||||
if (functionsTable.rows.length > 0) {
|
if (functionsTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Functions',
|
title: 'Functions',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -778,7 +768,7 @@ export class MarkdownDocumenter {
|
|||||||
if (interfacesTable.rows.length > 0) {
|
if (interfacesTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Interfaces',
|
title: 'Interfaces',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -788,7 +778,7 @@ export class MarkdownDocumenter {
|
|||||||
if (namespacesTable.rows.length > 0) {
|
if (namespacesTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Namespaces',
|
title: 'Namespaces',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -798,7 +788,7 @@ export class MarkdownDocumenter {
|
|||||||
if (variablesTable.rows.length > 0) {
|
if (variablesTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Variables',
|
title: 'Variables',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -808,7 +798,7 @@ export class MarkdownDocumenter {
|
|||||||
if (typeAliasesTable.rows.length > 0) {
|
if (typeAliasesTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Type Aliases',
|
title: 'Type Aliases',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -820,24 +810,24 @@ export class MarkdownDocumenter {
|
|||||||
* GENERATE PAGE: CLASS
|
* GENERATE PAGE: CLASS
|
||||||
*/
|
*/
|
||||||
private _writeClassTables(output: DocSection, apiClass: ApiClass): void {
|
private _writeClassTables(output: DocSection, apiClass: ApiClass): void {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const eventsTable: DocTable = new DocTable({
|
const eventsTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Property', 'Modifiers', 'Type', 'Description'],
|
headerTitles: ['Property', 'Modifiers', 'Type', 'Description'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const constructorsTable: DocTable = new DocTable({
|
const constructorsTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Constructor', 'Modifiers', 'Description'],
|
headerTitles: ['Constructor', 'Modifiers', 'Description'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const propertiesTable: DocTable = new DocTable({
|
const propertiesTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Property', 'Modifiers', 'Type', 'Description'],
|
headerTitles: ['Property', 'Modifiers', 'Type', 'Description'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const methodsTable: DocTable = new DocTable({
|
const methodsTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Method', 'Modifiers', 'Description'],
|
headerTitles: ['Method', 'Modifiers', 'Description'],
|
||||||
});
|
});
|
||||||
@ -896,7 +886,7 @@ export class MarkdownDocumenter {
|
|||||||
if (eventsTable.rows.length > 0) {
|
if (eventsTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Events',
|
title: 'Events',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -906,7 +896,7 @@ export class MarkdownDocumenter {
|
|||||||
if (constructorsTable.rows.length > 0) {
|
if (constructorsTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Constructors',
|
title: 'Constructors',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -916,7 +906,7 @@ export class MarkdownDocumenter {
|
|||||||
if (propertiesTable.rows.length > 0) {
|
if (propertiesTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Properties',
|
title: 'Properties',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -926,7 +916,7 @@ export class MarkdownDocumenter {
|
|||||||
if (methodsTable.rows.length > 0) {
|
if (methodsTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Methods',
|
title: 'Methods',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -938,9 +928,9 @@ export class MarkdownDocumenter {
|
|||||||
* GENERATE PAGE: ENUM
|
* GENERATE PAGE: ENUM
|
||||||
*/
|
*/
|
||||||
private _writeEnumTables(output: DocSection, apiEnum: ApiEnum): void {
|
private _writeEnumTables(output: DocSection, apiEnum: ApiEnum): void {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const enumMembersTable: DocTable = new DocTable({
|
const enumMembersTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Member', 'Value', 'Description'],
|
headerTitles: ['Member', 'Value', 'Description'],
|
||||||
});
|
});
|
||||||
@ -965,7 +955,7 @@ export class MarkdownDocumenter {
|
|||||||
if (enumMembersTable.rows.length > 0) {
|
if (enumMembersTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Enumeration Members',
|
title: 'Enumeration Members',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -980,19 +970,19 @@ export class MarkdownDocumenter {
|
|||||||
output: DocSection,
|
output: DocSection,
|
||||||
apiClass: ApiInterface
|
apiClass: ApiInterface
|
||||||
): void {
|
): void {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const eventsTable: DocTable = new DocTable({
|
const eventsTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Property', 'Modifiers', 'Type', 'Description'],
|
headerTitles: ['Property', 'Modifiers', 'Type', 'Description'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const propertiesTable: DocTable = new DocTable({
|
const propertiesTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Property', 'Modifiers', 'Type', 'Description', 'Default'],
|
headerTitles: ['Property', 'Modifiers', 'Type', 'Description', 'Default'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const methodsTable: DocTable = new DocTable({
|
const methodsTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Method', 'Description'],
|
headerTitles: ['Method', 'Description'],
|
||||||
});
|
});
|
||||||
@ -1040,7 +1030,7 @@ export class MarkdownDocumenter {
|
|||||||
if (eventsTable.rows.length > 0) {
|
if (eventsTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Events',
|
title: 'Events',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -1050,7 +1040,7 @@ export class MarkdownDocumenter {
|
|||||||
if (propertiesTable.rows.length > 0) {
|
if (propertiesTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Properties',
|
title: 'Properties',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -1060,7 +1050,7 @@ export class MarkdownDocumenter {
|
|||||||
if (methodsTable.rows.length > 0) {
|
if (methodsTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Methods',
|
title: 'Methods',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -1075,14 +1065,14 @@ export class MarkdownDocumenter {
|
|||||||
output: DocSection,
|
output: DocSection,
|
||||||
apiParameterListMixin: ApiParameterListMixin
|
apiParameterListMixin: ApiParameterListMixin
|
||||||
): void {
|
): void {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const parametersTable: DocTable = new DocTable({
|
const parametersTable = new DocTable({
|
||||||
configuration,
|
configuration,
|
||||||
headerTitles: ['Parameter', 'Type', 'Description'],
|
headerTitles: ['Parameter', 'Type', 'Description'],
|
||||||
});
|
});
|
||||||
for (const apiParameter of apiParameterListMixin.parameters) {
|
for (const apiParameter of apiParameterListMixin.parameters) {
|
||||||
const parameterDescription: DocSection = new DocSection({configuration});
|
const parameterDescription = new DocSection({configuration});
|
||||||
|
|
||||||
if (apiParameter.isOptional) {
|
if (apiParameter.isOptional) {
|
||||||
parameterDescription.appendNodesInParagraph([
|
parameterDescription.appendNodesInParagraph([
|
||||||
@ -1120,7 +1110,7 @@ export class MarkdownDocumenter {
|
|||||||
if (parametersTable.rows.length > 0) {
|
if (parametersTable.rows.length > 0) {
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
new DocHeading({
|
new DocHeading({
|
||||||
configuration: this._tsdocConfiguration,
|
configuration,
|
||||||
title: 'Parameters',
|
title: 'Parameters',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -1155,9 +1145,9 @@ export class MarkdownDocumenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _createParagraphForTypeExcerpt(excerpt: Excerpt): DocParagraph {
|
private _createParagraphForTypeExcerpt(excerpt: Excerpt): DocParagraph {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const paragraph: DocParagraph = new DocParagraph({configuration});
|
const paragraph = new DocParagraph({configuration});
|
||||||
if (!excerpt.text.trim()) {
|
if (!excerpt.text.trim()) {
|
||||||
paragraph.appendNode(
|
paragraph.appendNode(
|
||||||
new DocPlainText({configuration, text: '(not declared)'})
|
new DocPlainText({configuration, text: '(not declared)'})
|
||||||
@ -1182,13 +1172,13 @@ export class MarkdownDocumenter {
|
|||||||
docNodeContainer: DocNodeContainer,
|
docNodeContainer: DocNodeContainer,
|
||||||
token: ExcerptToken
|
token: ExcerptToken
|
||||||
): void {
|
): void {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
// Markdown doesn't provide a standardized syntax for hyperlinks inside code
|
// Markdown doesn't provide a standardized syntax for hyperlinks inside code
|
||||||
// spans, so we will render the type expression as DocPlainText. Instead of
|
// spans, so we will render the type expression as DocPlainText. Instead of
|
||||||
// creating multiple DocParagraphs, we can simply discard any newlines and
|
// creating multiple DocParagraphs, we can simply discard any newlines and
|
||||||
// let the renderer do normal word-wrapping.
|
// let the renderer do normal word-wrapping.
|
||||||
const unwrappedTokenText: string = token.text.replace(/[\r\n]+/g, ' ');
|
const unwrappedTokenText = token.text.replace(/[\r\n]+/g, ' ');
|
||||||
|
|
||||||
// If it's hyperlinkable, then append a DocLinkTag
|
// If it's hyperlinkable, then append a DocLinkTag
|
||||||
if (token.kind === ExcerptTokenKind.Reference && token.canonicalReference) {
|
if (token.kind === ExcerptTokenKind.Reference && token.canonicalReference) {
|
||||||
@ -1220,9 +1210,9 @@ export class MarkdownDocumenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _createTitleCell(apiItem: ApiItem, plain = false): DocTableCell {
|
private _createTitleCell(apiItem: ApiItem, plain = false): DocTableCell {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const text: string = Utilities.getConciseSignature(apiItem);
|
const text = Utilities.getConciseSignature(apiItem);
|
||||||
|
|
||||||
return new DocTableCell({configuration}, [
|
return new DocTableCell({configuration}, [
|
||||||
new DocParagraph({configuration}, [
|
new DocParagraph({configuration}, [
|
||||||
@ -1263,9 +1253,9 @@ export class MarkdownDocumenter {
|
|||||||
* cast.
|
* cast.
|
||||||
*/
|
*/
|
||||||
private _createDescriptionCell(apiItem: ApiItem): DocTableCell {
|
private _createDescriptionCell(apiItem: ApiItem): DocTableCell {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const section: DocSection = new DocSection({configuration});
|
const section = new DocSection({configuration});
|
||||||
|
|
||||||
if (ApiReleaseTagMixin.isBaseClassOf(apiItem)) {
|
if (ApiReleaseTagMixin.isBaseClassOf(apiItem)) {
|
||||||
if (apiItem.releaseTag === ReleaseTag.Beta) {
|
if (apiItem.releaseTag === ReleaseTag.Beta) {
|
||||||
@ -1305,7 +1295,7 @@ export class MarkdownDocumenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _createDefaultCell(apiItem: ApiItem): DocTableCell {
|
private _createDefaultCell(apiItem: ApiItem): DocTableCell {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
if (apiItem instanceof ApiDocumentedItem) {
|
if (apiItem instanceof ApiDocumentedItem) {
|
||||||
const block = apiItem.tsdocComment?.customBlocks.find(block => {
|
const block = apiItem.tsdocComment?.customBlocks.find(block => {
|
||||||
@ -1323,9 +1313,9 @@ export class MarkdownDocumenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _createModifiersCell(apiItem: ApiItem): DocTableCell {
|
private _createModifiersCell(apiItem: ApiItem): DocTableCell {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const section: DocSection = new DocSection({configuration});
|
const section = new DocSection({configuration});
|
||||||
|
|
||||||
const codes = [];
|
const codes = [];
|
||||||
|
|
||||||
@ -1370,9 +1360,9 @@ export class MarkdownDocumenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _createPropertyTypeCell(apiItem: ApiItem): DocTableCell {
|
private _createPropertyTypeCell(apiItem: ApiItem): DocTableCell {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const section: DocSection = new DocSection({configuration});
|
const section = new DocSection({configuration});
|
||||||
|
|
||||||
if (apiItem instanceof ApiPropertyItem) {
|
if (apiItem instanceof ApiPropertyItem) {
|
||||||
section.appendNode(
|
section.appendNode(
|
||||||
@ -1384,9 +1374,9 @@ export class MarkdownDocumenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _createInitializerCell(apiItem: ApiItem): DocTableCell {
|
private _createInitializerCell(apiItem: ApiItem): DocTableCell {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
|
|
||||||
const section: DocSection = new DocSection({configuration});
|
const section = new DocSection({configuration});
|
||||||
|
|
||||||
if (ApiInitializerMixin.isBaseClassOf(apiItem)) {
|
if (ApiInitializerMixin.isBaseClassOf(apiItem)) {
|
||||||
if (apiItem.initializerExcerpt) {
|
if (apiItem.initializerExcerpt) {
|
||||||
@ -1403,8 +1393,8 @@ export class MarkdownDocumenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _writeBetaWarning(output: DocSection): void {
|
private _writeBetaWarning(output: DocSection): void {
|
||||||
const configuration: TSDocConfiguration = this._tsdocConfiguration;
|
const configuration = this._tsdocConfiguration;
|
||||||
const betaWarning: string =
|
const betaWarning =
|
||||||
'This API is provided as a preview for developers and may change' +
|
'This API is provided as a preview for developers and may change' +
|
||||||
' based on feedback that we receive. Do not use this API in a production environment.';
|
' based on feedback that we receive. Do not use this API in a production environment.';
|
||||||
output.appendNode(
|
output.appendNode(
|
||||||
@ -1449,7 +1439,7 @@ export class MarkdownDocumenter {
|
|||||||
let baseName = '';
|
let baseName = '';
|
||||||
for (const hierarchyItem of apiItem.getHierarchy()) {
|
for (const hierarchyItem of apiItem.getHierarchy()) {
|
||||||
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
|
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
|
||||||
let qualifiedName: string = hierarchyItem.displayName;
|
let qualifiedName = hierarchyItem.displayName;
|
||||||
if (ApiParameterListMixin.isBaseClassOf(hierarchyItem)) {
|
if (ApiParameterListMixin.isBaseClassOf(hierarchyItem)) {
|
||||||
if (hierarchyItem.overloadIndex > 1) {
|
if (hierarchyItem.overloadIndex > 1) {
|
||||||
// Subtract one for compatibility with earlier releases of API Documenter.
|
// Subtract one for compatibility with earlier releases of API Documenter.
|
||||||
@ -1479,7 +1469,7 @@ export class MarkdownDocumenter {
|
|||||||
let suffix = '';
|
let suffix = '';
|
||||||
for (const hierarchyItem of apiItem.getHierarchy()) {
|
for (const hierarchyItem of apiItem.getHierarchy()) {
|
||||||
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
|
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
|
||||||
let qualifiedName: string = Utilities.getSafeFilenameForName(
|
let qualifiedName = Utilities.getSafeFilenameForName(
|
||||||
hierarchyItem.displayName
|
hierarchyItem.displayName
|
||||||
);
|
);
|
||||||
if (ApiParameterListMixin.isBaseClassOf(hierarchyItem)) {
|
if (ApiParameterListMixin.isBaseClassOf(hierarchyItem)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user