From 1ec2901f565829dcea987efc2655032347fe3491 Mon Sep 17 00:00:00 2001 From: Qjuh <76154676+Qjuh@users.noreply.github.com> Date: Fri, 1 Dec 2023 02:11:59 +0100 Subject: [PATCH] feat(website): type parameters on methods and overloads (#9998) * feat(website): type parameters on methods and overloads * refactor: add collapsible parameter list --- .../model/method/MethodDocumentation.tsx | 27 ++++++++++++------- apps/website/src/util/model.ts | 18 +++++++------ 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/apps/website/src/components/model/method/MethodDocumentation.tsx b/apps/website/src/components/model/method/MethodDocumentation.tsx index 27497dc06..bfb735d77 100644 --- a/apps/website/src/components/model/method/MethodDocumentation.tsx +++ b/apps/website/src/components/model/method/MethodDocumentation.tsx @@ -1,11 +1,13 @@ -import type { - ApiDeclaredItem, - ApiItemContainerMixin, - ApiMethod, - ApiMethodSignature, +import { + ApiItemKind, + type ApiDeclaredItem, + type ApiItemContainerMixin, + type ApiMethod, + type ApiMethodSignature, } from '@discordjs/api-extractor-model'; +import { ParameterSection } from '~/components/documentation/section/ParametersSection'; +import { TypeParameterSection } from '~/components/documentation/section/TypeParametersSection'; import { InheritanceText } from '../../InheritanceText'; -import { ParameterTable } from '../../ParameterTable'; import { TSDoc } from '../../documentation/tsdoc/TSDoc'; export interface MethodDocumentationProps { @@ -15,15 +17,22 @@ export interface MethodDocumentationProps { export function MethodDocumentation({ method, inheritedFrom }: MethodDocumentationProps) { const parent = method.parent as ApiDeclaredItem; + const firstOverload = method + .getMergedSiblings() + .find((meth): meth is ApiMethod => meth.kind === ApiItemKind.Method && (meth as ApiMethod).overloadIndex === 1) + ?.tsdocComment; - if (!(method.tsdocComment?.summarySection || method.parameters.length > 0)) { + if (!(method.tsdocComment?.summarySection || firstOverload?.summarySection || method.parameters.length > 0)) { return null; } return (