Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _buildTocItems2(apiItems: ReadonlyArray): IYamlTocItem[] {
const tocItems: IYamlTocItem[] = [];
for (const apiItem of apiItems) {
let tocItem: IYamlTocItem;
if (apiItem.kind === ApiItemKind.Namespace) {
// Namespaces don't have nodes yet
tocItem = {
name: apiItem.displayName
};
} else {
if (this._shouldEmbed(apiItem.kind)) {
// Don't generate table of contents items for embedded definitions
continue;
}
if (apiItem.kind === ApiItemKind.Package) {
tocItem = {
name: PackageName.getUnscopedName(apiItem.displayName),
uid: this._getUid(apiItem)
};
} else {
private _buildTocItems(apiItems: ReadonlyArray): IYamlTocItem[] {
const tocItems: IYamlTocItem[] = [];
for (const apiItem of apiItems) {
let tocItem: IYamlTocItem;
if (apiItem.kind === ApiItemKind.Namespace) {
// Namespaces don't have nodes yet
tocItem = {
name: apiItem.displayName
};
} else {
if (this._shouldEmbed(apiItem.kind)) {
// Don't generate table of contents items for embedded definitions
continue;
}
if (apiItem.kind === ApiItemKind.Package) {
tocItem = {
name: PackageName.getUnscopedName(apiItem.displayName),
uid: this._getUid(apiItem)
};
} else {
output.appendNode(new DocHeading({ configuration, title: `${scopedName} class` }));
break;
case ApiItemKind.Enum:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} enum` }));
break;
case ApiItemKind.Interface:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} interface` }));
break;
case ApiItemKind.Method:
case ApiItemKind.MethodSignature:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} method` }));
break;
case ApiItemKind.Function:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} function` }));
break;
case ApiItemKind.Namespace:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} namespace` }));
break;
case ApiItemKind.Package:
const unscopedPackageName: string = PackageName.getUnscopedName(apiItem.displayName);
console.log(apiItem.displayName);
output.appendNode(new DocHeading({ configuration, title: `${unscopedPackageName} package` }));
break;
case ApiItemKind.Property:
case ApiItemKind.PropertySignature:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} property` }));
break;
case ApiItemKind.TypeAlias:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} type` }));
break;
case ApiItemKind.Variable:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} variable` }));
break;
case ApiItemKind.Constructor:
case ApiItemKind.ConstructSignature:
output.appendNode(new DocHeading({ configuration, title: scopedName }));
break;
case ApiItemKind.Method:
case ApiItemKind.MethodSignature:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} method` }));
break;
case ApiItemKind.Function:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} function` }));
break;
case ApiItemKind.Model:
output.appendNode(new DocHeading({ configuration, title: `API Reference` }));
break;
case ApiItemKind.Namespace:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} namespace` }));
break;
case ApiItemKind.Package:
console.log(`Writing ${apiItem.displayName} package`);
const unscopedPackageName: string = PackageName.getUnscopedName(apiItem.displayName);
output.appendNode(new DocHeading({ configuration, title: `${unscopedPackageName} package` }));
break;
case ApiItemKind.Property:
case ApiItemKind.PropertySignature:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} property` }));
break;
case ApiItemKind.TypeAlias:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} type` }));
break;
case ApiItemKind.Variable:
output.appendNode(new DocHeading({ configuration, title: `${scopedName} variable` }));
private _flattenNamespaces(items: ReadonlyArray): ApiItem[] {
const flattened: ApiItem[] = [];
for (const item of items) {
if (item.kind === ApiItemKind.Namespace) {
flattened.push(...this._flattenNamespaces(item.members));
} else {
flattened.push(item);
}
}
return flattened;
}