Skip to content

Commit 1c23ab7

Browse files
authored
docs(clients): remove unexpected STS commands (#2285)
This change also adds waiters section to the ToC
1 parent 0ffd712 commit 1c23ab7

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

packages/client-documentation-generator/src/sdk-client-toc-plugin.ts

+23-6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class SdkClientTocPlugin extends RendererComponent {
1818
private commandsNavigationItem?: NavigationItem;
1919
private clientsNavigationItem?: NavigationItem;
2020
private paginatorsNavigationItem?: NavigationItem;
21+
private waitersNavigationItem?: NavigationItem;
2122
private clientDir?: string;
2223

2324
initialize() {
@@ -53,11 +54,17 @@ export class SdkClientTocPlugin extends RendererComponent {
5354
this.clientsNavigationItem = new NavigationItem("Clients", void 0, page.toc);
5455
this.commandsNavigationItem = new NavigationItem("Commands", void 0, page.toc);
5556
this.paginatorsNavigationItem = new NavigationItem("Paginators", void 0, page.toc);
57+
this.waitersNavigationItem = new NavigationItem("Waiters", void 0, page.toc);
5658
}
5759

5860
this.buildToc(model, trail, page.toc, tocRestriction);
5961
}
6062

63+
// Confirm declaration comes from the same folder as the client class
64+
private belongsToClientPackage(model: DeclarationReflection): boolean {
65+
return this.clientDir && model.sources?.[0].file?.fullFileName.indexOf(this.clientDir) === 0;
66+
}
67+
6168
private isClient(model: DeclarationReflection): boolean {
6269
const { extendedTypes = [] } = model;
6370
return (
@@ -66,28 +73,36 @@ export class SdkClientTocPlugin extends RendererComponent {
6673
(model.name.endsWith("Client") /* Modular client like S3Client */ ||
6774
extendedTypes.filter((reference) => (reference as ReferenceType).name === `${model.name}Client`).length > 0) &&
6875
/* Filter out other client classes that not sourced from the same directory as current client. e.g. STS, SSO */
69-
this.clientDir &&
70-
dirname(model.sources[0]?.file.fullFileName) === this.clientDir
76+
this.belongsToClientPackage(model)
7177
);
7278
}
7379

7480
private isCommand(model: DeclarationReflection): boolean {
7581
return (
7682
model.kindOf(ReflectionKind.Class) &&
77-
model.getFullName() !== "Command" && // Exclude the Smithy Command class.
7883
model.name.endsWith("Command") &&
79-
model.children?.some((child) => child.name === "resolveMiddleware")
84+
model.children?.some((child) => child.name === "resolveMiddleware") &&
85+
this.belongsToClientPackage(model)
8086
);
8187
}
8288

8389
private isPaginator(model: DeclarationReflection): boolean {
84-
return model.name.startsWith("paginate") && model.kindOf(ReflectionKind.Function);
90+
return (
91+
model.name.startsWith("paginate") && model.kindOf(ReflectionKind.Function) && this.belongsToClientPackage(model)
92+
);
8593
}
8694

8795
private isInputOrOutput(model: DeclarationReflection): boolean {
8896
return (
8997
model.kindOf(ReflectionKind.Interface) &&
90-
(model.name.endsWith("CommandInput") || model.name.endsWith("CommandOutput"))
98+
(model.name.endsWith("CommandInput") || model.name.endsWith("CommandOutput")) &&
99+
this.belongsToClientPackage(model)
100+
);
101+
}
102+
103+
private isWaiter(model: DeclarationReflection): boolean {
104+
return (
105+
model.name.startsWith("waitFor") && model.kindOf(ReflectionKind.Function) && this.belongsToClientPackage(model)
91106
);
92107
}
93108

@@ -128,6 +143,8 @@ export class SdkClientTocPlugin extends RendererComponent {
128143
NavigationItem.create(child, this.paginatorsNavigationItem, true);
129144
} else if (this.isInputOrOutput(child)) {
130145
NavigationItem.create(child, this.commandsNavigationItem, true);
146+
} else if (this.isWaiter(child)) {
147+
NavigationItem.create(child, this.waitersNavigationItem, true);
131148
} else {
132149
const item = NavigationItem.create(child, parent, true);
133150
if (trail.includes(child)) {

0 commit comments

Comments
 (0)