Skip to content

docs(packages): fix aws client link in globals.html #2259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { isAbsolute, join, relative, resolve, sep } from "path";
import { BindOption } from "typedoc";
import { BindOption, ProjectReflection, Reflection } from "typedoc";
import { Component, RendererComponent } from "typedoc/dist/lib/output/components";
import { PageEvent } from "typedoc/dist/lib/output/events";
import { NavigationItem } from "typedoc/dist/lib/output/models/NavigationItem";

const isClientModel = (model: Reflection | undefined) => model?.sources[0]?.fileName.startsWith(`clients${sep}`);

const PROJECT_ROOT = join(__dirname, "..", "..", "..", "..");
@Component({ name: "SdkIndexLinkClientPlugin" })
export class SdkIndexLinkClientPlugin extends RendererComponent {
Expand Down Expand Up @@ -46,6 +48,15 @@ export class SdkIndexLinkClientPlugin extends RendererComponent {
if (page.model._skipRendering) {
page.preventDefault();
}

// Update the client doc link int globals.html
if (page.filename.endsWith("globals.html")) {
(page.model as ProjectReflection).children.filter(isClientModel).forEach((clientModel) => {
const clientName = clientModel.sources[0].fileName.split(sep)[1];
const clientDocDir = clientDocsPattern.replace(/{{CLIENT}}/g, clientName);
clientModel.url = join(clientDocDir, "index.html");
});
}
}

/**
Expand Down Expand Up @@ -89,6 +100,6 @@ export class SdkIndexLinkClientPlugin extends RendererComponent {
}

private isClient(item: NavigationItem): boolean {
return item?.reflection?.sources[0].fileName.startsWith(`clients${sep}`);
return isClientModel(item?.reflection);
}
}