Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _renderMarkdown(docSection: DocSection, contextApiItem: ApiItem): string {
const stringBuilder: StringBuilder = new StringBuilder();
this._markdownEmitter.emit(stringBuilder, docSection, {
contextApiItem,
onGetFilenameForApiItem: (apiItem: ApiItem) => {
// NOTE: GitHub's markdown renderer does not resolve relative hyperlinks correctly
// unless they start with "./" or "../".
return `xref:${this._getUid(apiItem)}`;
}
});
return stringBuilder.toString().trim();
}
case ApiItemKind.PropertySignature:
break;
case ApiItemKind.TypeAlias:
break;
case ApiItemKind.Variable:
break;
default:
throw new Error('Unsupported API item kind: ' + apiItem.kind);
}
if (appendRemarks) {
this._writeRemarksSection(output, apiItem);
}
const filename: string = path.join(this._outputFolder, this._getFilenameForApiItem(apiItem));
const stringBuilder: StringBuilder = new StringBuilder();
stringBuilder.append('\n\n');
this._markdownEmitter.emit(stringBuilder, output, {
contextApiItem: apiItem,
onGetFilenameForApiItem: (apiItemForFilename: ApiItem) => {
return this._getLinkFilenameForApiItem(apiItemForFilename);
}
});
let pageContent: string = stringBuilder.toString();
if (this._pluginLoader.markdownDocumenterFeature) {
// Allow the plugin to customize the pageContent
const eventArgs: IMarkdownDocumenterFeatureOnBeforeWritePageArgs = {
apiItem: apiItem,
let exampleNumber: number = 1;
for (const exampleBlock of exampleBlocks) {
const heading: string = exampleBlocks.length > 1 ? `Example ${exampleNumber}` : 'Example';
output.appendNode(new DocHeading({ configuration: this._tsdocConfiguration, title: heading }));
this._appendSection(output, exampleBlock.content);
++exampleNumber;
}
}
}
const filename: string = path.join(this._outputFolder, this._getFilenameForApiItem(apiItem, true));
const stringBuilder: StringBuilder = new StringBuilder();
this._markdownEmitter.emit(stringBuilder, output, {
contextApiItem: apiItem,
onGetFilenameForApiItem: (apiItemForFilename: ApiItem) => {
return this._getLinkFilenameForApiItem(apiItemForFilename);
},
});
FileSystem.writeFile(filename, stringBuilder.toString(), {
convertLineEndings: NewlineKind.CrLf,
});
}
public getModifiedText(): string {
const output: StringBuilder = new StringBuilder();
this._writeModifiedText({
output,
separatorOverride: undefined
});
return output.toString();
}