Skip to content

Commit e475b63

Browse files
feat(website): show descriptions for @typeParam blocks (#8523)
1 parent 673262d commit e475b63

File tree

18 files changed

+126
-62
lines changed

18 files changed

+126
-62
lines changed

packages/builders/src/components/ActionRow.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalAction
2222

2323
/**
2424
* Represents an action row component
25+
*
26+
* @typeParam T - The types of components this action row holds
2527
*/
2628
export class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentBuilder<
2729
APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>
@@ -56,6 +58,9 @@ export class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentBu
5658
return this;
5759
}
5860

61+
/**
62+
* {@inheritDoc JSONEncodable.toJSON}
63+
*/
5964
public toJSON(): APIActionRowComponent<ReturnType<T['toJSON']>> {
6065
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
6166
return {

packages/builders/src/components/Component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export type AnyAPIActionRowComponent = APIActionRowComponentTypes | APIActionRow
1010

1111
/**
1212
* Represents a discord component
13+
*
14+
* @typeParam DataType - The type of internal API data that is stored within the component
1315
*/
1416
export abstract class ComponentBuilder<
1517
DataType extends Partial<APIBaseComponent<ComponentType>> = APIBaseComponent<ComponentType>,
@@ -20,6 +22,9 @@ export abstract class ComponentBuilder<
2022
*/
2123
public readonly data: Partial<DataType>;
2224

25+
/**
26+
* {@inheritDoc JSONEncodable.toJSON}
27+
*/
2328
public abstract toJSON(): AnyAPIActionRowComponent;
2429

2530
public constructor(data: Partial<DataType>) {

packages/builders/src/components/button/Button.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ export class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
8585
return this;
8686
}
8787

88+
/**
89+
* {@inheritDoc JSONEncodable.toJSON}
90+
*/
8891
public toJSON(): APIButtonComponent {
8992
validateRequiredButtonParameters(
9093
this.data.style,

packages/builders/src/components/selectMenu/SelectMenu.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ export class SelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent>
116116
return this;
117117
}
118118

119+
/**
120+
* {@inheritDoc JSONEncodable.toJSON}
121+
*/
119122
public toJSON(): APISelectMenuComponent {
120123
validateRequiredSelectMenuParameters(this.options, this.data.custom_id);
121124
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions

packages/builders/src/components/selectMenu/SelectMenuOption.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v10';
2+
import type { JSONEncodable } from '../../util/jsonEncodable';
23

34
import {
45
defaultValidator,
@@ -10,7 +11,7 @@ import {
1011
/**
1112
* Represents a option within a select menu component
1213
*/
13-
export class SelectMenuOptionBuilder {
14+
export class SelectMenuOptionBuilder implements JSONEncodable<APISelectMenuOption> {
1415
public constructor(public data: Partial<APISelectMenuOption> = {}) {}
1516

1617
/**
@@ -63,6 +64,9 @@ export class SelectMenuOptionBuilder {
6364
return this;
6465
}
6566

67+
/**
68+
* {@inheritDoc JSONEncodable.toJSON}
69+
*/
6670
public toJSON(): APISelectMenuOption {
6771
validateRequiredSelectMenuOptionParameters(this.data.label, this.data.value);
6872
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions

packages/builders/src/components/textInput/TextInput.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ import {
1010
labelValidator,
1111
textInputStyleValidator,
1212
} from './Assertions';
13+
import type { Equatable } from '../../util/equatable';
1314
import { isJSONEncodable, type JSONEncodable } from '../../util/jsonEncodable';
1415
import { customIdValidator } from '../Assertions';
1516
import { ComponentBuilder } from '../Component';
1617

17-
export class TextInputBuilder extends ComponentBuilder<APITextInputComponent> {
18+
export class TextInputBuilder
19+
extends ComponentBuilder<APITextInputComponent>
20+
implements Equatable<JSONEncodable<APITextInputComponent> | APITextInputComponent>
21+
{
1822
public constructor(data?: APITextInputComponent & { type?: ComponentType.TextInput }) {
1923
super({ type: ComponentType.TextInput, ...data });
2024
}
@@ -99,6 +103,9 @@ export class TextInputBuilder extends ComponentBuilder<APITextInputComponent> {
99103
return this;
100104
}
101105

106+
/**
107+
* {@inheritDoc JSONEncodable.toJSON}
108+
*/
102109
public toJSON(): APITextInputComponent {
103110
validateRequiredParameters(this.data.custom_id, this.data.style, this.data.label);
104111
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
@@ -107,6 +114,9 @@ export class TextInputBuilder extends ComponentBuilder<APITextInputComponent> {
107114
} as APITextInputComponent;
108115
}
109116

117+
/**
118+
* {@inheritDoc Equatable.equals}
119+
*/
110120
public equals(other: JSONEncodable<APITextInputComponent> | APITextInputComponent): boolean {
111121
if (isJSONEncodable(other)) {
112122
return isEqual(other.toJSON(), this.data);

packages/builders/src/interactions/slashCommands/SlashCommandBuilder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class SlashCommandBuilder {
4949
* Whether the command is enabled by default when the app is added to a guild
5050
*
5151
* @deprecated This property is deprecated and will be removed in the future.
52-
* You should use `setDefaultMemberPermissions` or `setDMPermission` instead.
52+
* You should use {@link (SlashCommandBuilder:class).setDefaultMemberPermissions} or {@link (SlashCommandBuilder:class).setDMPermission} instead.
5353
*/
5454
public readonly default_permission: boolean | undefined = undefined;
5555

@@ -89,7 +89,7 @@ export class SlashCommandBuilder {
8989
* @param value - Whether or not to enable this command by default
9090
*
9191
* @see https://discord.com/developers/docs/interactions/application-commands#permissions
92-
* @deprecated Use `setDefaultMemberPermissions` or `setDMPermission` instead.
92+
* @deprecated Use {@link (SlashCommandBuilder:class).setDefaultMemberPermissions} or {@link (SlashCommandBuilder:class).setDMPermission} instead.
9393
*/
9494
public setDefaultPermission(value: boolean) {
9595
// Assert the value matches the conditions

packages/builders/src/util/equatable.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Represents a structure that can be checked against another
3+
* given structure for equality
4+
*
5+
* @typeParam T - The type of object to compare the current object to
6+
*/
17
export interface Equatable<T> {
28
/**
39
* Whether or not this is equal to another structure

packages/builders/src/util/jsonEncodable.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Represents an object capable of representing itself as a JSON object
3+
*
4+
* @typeParam T - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs.
5+
*/
16
export interface JSONEncodable<T> {
27
/**
38
* Transforms this object to its JSON format

packages/collection/src/collection.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export interface Collection<K, V> extends Map<K, V> {
2828
/**
2929
* A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
3030
* an ID, for significantly improved performance and ease-of-use.
31+
*
32+
* @typeParam K - The key type this collection holds
33+
* @typeParam V - The value type this collection holds
3134
*/
3235
export class Collection<K, V> extends Map<K, V> {
3336
/**

0 commit comments

Comments
 (0)