mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
refactor(website): remove unneccessary addPackageToModel function (#9983)
* types: fix links in @deprecated tags * Merge branch 'main' into fix/deprecated-links-d.ts * fix: searchIndices * refactor: apply review suggestions * refactor: remove addPackageToModel function * fix: event links in search index * fix: wrong overload condition
This commit is contained in:
@@ -11,6 +11,8 @@ import {
|
||||
type Parameter,
|
||||
type ApiFunction,
|
||||
ApiDeclaredItem,
|
||||
type ApiMethod,
|
||||
type ApiMethodSignature,
|
||||
} from '@discordjs/api-extractor-model';
|
||||
import type { DocNode, DocParagraph, DocPlainText } from '@microsoft/tsdoc';
|
||||
import { type Meaning, ModuleSource } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference.js';
|
||||
@@ -23,6 +25,10 @@ export function findPackage(model: ApiModel, name: string): ApiPackage | undefin
|
||||
| undefined;
|
||||
}
|
||||
|
||||
function hasOverloadIndex(item: ApiItem): item is ApiFunction | ApiMethod | ApiMethodSignature {
|
||||
return 'overloadIndex' in item;
|
||||
}
|
||||
|
||||
export function generatePath(items: readonly ApiItem[], version: string) {
|
||||
let path = '/docs/packages';
|
||||
|
||||
@@ -36,17 +42,19 @@ export function generatePath(items: readonly ApiItem[], version: string) {
|
||||
path += `/${item.displayName}`;
|
||||
break;
|
||||
case ApiItemKind.Function:
|
||||
// eslint-disable-next-line no-case-declarations
|
||||
const functionItem = item as ApiFunction;
|
||||
path += `/${functionItem.displayName}${
|
||||
functionItem.overloadIndex && functionItem.overloadIndex > 1 ? `:${functionItem.overloadIndex}` : ''
|
||||
path += `/${item.displayName}${
|
||||
hasOverloadIndex(item) && item.overloadIndex > 1 ? `:${item.overloadIndex}` : ''
|
||||
}:${item.kind}`;
|
||||
break;
|
||||
case ApiItemKind.Property:
|
||||
case ApiItemKind.Method:
|
||||
case ApiItemKind.MethodSignature:
|
||||
path += `#${item.displayName}${
|
||||
hasOverloadIndex(item) && item.overloadIndex > 1 ? `:${item.overloadIndex}` : ''
|
||||
}`;
|
||||
break;
|
||||
case ApiItemKind.Property:
|
||||
case ApiItemKind.PropertySignature:
|
||||
// TODO: Take overloads into account
|
||||
case ApiItemKind.Event:
|
||||
path += `#${item.displayName}`;
|
||||
break;
|
||||
default:
|
||||
@@ -55,8 +63,8 @@ export function generatePath(items: readonly ApiItem[], version: string) {
|
||||
}
|
||||
|
||||
return path.includes('@discordjs/')
|
||||
? path.replace(/@discordjs\/(.*)\/(.*)?/, `$1/${version}/$2`)
|
||||
: path.replace(/(.*)\/(.*)?/, `$1/${version}/$2`);
|
||||
? path.replace(/@discordjs\/(?<package>.*)\/(?<member>.*)?/, `$<package>/${version}/$<member>`)
|
||||
: path.replace(/(?<oackage>.*)\/(?<member>.*)?/, `$<package>/${version}/$<member>`);
|
||||
}
|
||||
|
||||
export function resolveDocComment(item: ApiDeclaredItem) {
|
||||
|
||||
Reference in New Issue
Block a user