Skip to content

Commit

Permalink
fix doc links for >1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Sep 28, 2023
1 parent 133556d commit 0f3b21d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const truncate = (str: string, maxLen: number) => {
export let defaultVersion: string;
export let versions: Array<string>;
const minSupport = "1.0.0";
const minNewLayout = "1.8.0";
export function refreshVersions() {
defaultVersion = execSync("npm show oceanic.js version").toString().slice(0, -1);
versions = (JSON.parse(execSync("npm show oceanic.js versions --json").toString()) as Array<string>).filter(v => !v.includes("-") && gte(v, minSupport));
Expand Down Expand Up @@ -95,7 +96,10 @@ export async function getVersion(version: string): Promise<Root | null> {
}

export function docsURL(version: string, type: "class" | "interface" | "enum" | "typeAlias", module: string, name: string, otherName?: string) {
let typeName: string;
let typeName: string, includeModule = true;
if (gte(version, minNewLayout)) {
includeModule = module === name;
}
switch (type) {
case "class": {
typeName = "classes";
Expand All @@ -121,7 +125,7 @@ export function docsURL(version: string, type: "class" | "interface" | "enum" |
return `https://docs.oceanic.ws/v${version}#type=${type as string}&module=${module}&name=${name}&otherName=${otherName || "undefined"}`;
}
}
return `https://docs.oceanic.ws/v${version}/${typeName}/${module.replace(/\//g, "_")}.${name}.html${otherName ? `#${otherName}` : ""}`;
return `https://docs.oceanic.ws/v${version}/${typeName}/${includeModule ? `${module.replace(/\//g, "_")}.` : ""}${name}.html${otherName ? `#${otherName}` : ""}`;
}

export async function find(version: string, name: string) {
Expand Down

0 comments on commit 0f3b21d

Please sign in to comment.