Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[kGetSafeName](apiItem) {
let safeName = this[kSafeNames].get(apiItem);
if (!safeName) {
safeName = apiItem.displayName;
if (safeName === ts.InternalSymbolName.Computed && apiItem instanceof ApiDeclaredItem) {
const match = /\[[^\[\]]+\]/.exec(apiItem.excerpt.text);
if (match) {
safeName = match[0];
}
}
if (this[kCollidesWithItemsOfSameName](apiItem)) {
safeName += `_${apiItem.kind}`;
}
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
if (ApiParameterListMixin.isBaseClassOf(apiItem)) {
if (apiItem.overloadIndex > 0) {
safeName += `_${apiItem.overloadIndex}`;
}
}
this[kSafeNames].set(apiItem, safeName);
}
return safeName;
}
protected _getUid(apiItem: ApiItem): string {
let result: string = '';
for (const hierarchyItem of apiItem.getHierarchy()) {
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
let qualifiedName: string = hierarchyItem.displayName;
if (ApiParameterListMixin.isBaseClassOf(hierarchyItem)) {
if (hierarchyItem.overloadIndex > 1) {
// Subtract one for compatibility with earlier releases of API Documenter.
// (This will get revamped when we fix GitHub issue #1308)
qualifiedName += `_${hierarchyItem.overloadIndex - 1}`;
}
}
switch (hierarchyItem.kind) {
case ApiItemKind.Model:
case ApiItemKind.EntryPoint:
break;
case ApiItemKind.Package:
result += PackageName.getUnscopedName(hierarchyItem.displayName);
break;
default:
result += '.';
private _getFilenameForApiItem(apiItem: ApiItem, withExtension = false): string {
let baseName: string = '';
for (const hierarchyItem of apiItem.getHierarchy()) {
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
let qualifiedName: string = hierarchyItem.displayName;
if (ApiParameterListMixin.isBaseClassOf(hierarchyItem)) {
if (hierarchyItem.overloadIndex > 0) {
qualifiedName += `_${hierarchyItem.overloadIndex}`;
}
}
switch (hierarchyItem.kind) {
case ApiItemKind.Model:
case ApiItemKind.EntryPoint:
break;
case ApiItemKind.Package:
baseName = withExtension
? PackageName.getUnscopedName(hierarchyItem.displayName)
: hierarchyItem.displayName;
break;
default:
baseName += '.' + qualifiedName;
private _getFilenameForApiItem(apiItem: ApiItem): string {
if (apiItem.kind === ApiItemKind.Model) {
return 'index.md';
}
let baseName: string = '';
for (const hierarchyItem of apiItem.getHierarchy()) {
// For overloaded methods, add a suffix such as "MyClass.myMethod_2".
let qualifiedName: string = Utilities.getSafeFilenameForName(hierarchyItem.displayName);
if (ApiParameterListMixin.isBaseClassOf(hierarchyItem)) {
if (hierarchyItem.overloadIndex > 1) {
// Subtract one for compatibility with earlier releases of API Documenter.
// (This will get revamped when we fix GitHub issue #1308)
qualifiedName += `_${hierarchyItem.overloadIndex - 1}`;
}
}
switch (hierarchyItem.kind) {
case ApiItemKind.Model:
case ApiItemKind.EntryPoint:
break;
case ApiItemKind.Package:
baseName = Utilities.getSafeFilenameForName(PackageName.getUnscopedName(hierarchyItem.displayName));
break;
default:
baseName += '.' + qualifiedName;
public static getConciseSignature(apiItem: ApiItem): string {
if (ApiParameterListMixin.isBaseClassOf(apiItem)) {
return apiItem.displayName + '(' + apiItem.parameters.map(x => x.name).join(', ') + ')';
}
return apiItem.displayName;
}