Skip to content

Commit

Permalink
docs(packages): fix aws client link in globals.html (#2259)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP committed Apr 15, 2021
1 parent 4f9f4a7 commit 32b563b
Showing 1 changed file with 13 additions and 2 deletions.
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);
}
}

0 comments on commit 32b563b

Please sign in to comment.