mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
* feat(website): show package members in a sidebar * fix: put response instead of loader * Apply suggestions from code review Co-authored-by: Noel <buechler.noel@outlook.com> * chore: make requested changes * refactor: make only package list scrollable * feat: make sidebar mobile responsive * fix: breakpoints for sidebar Co-authored-by: Noel <buechler.noel@outlook.com>
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import {
|
|
type ApiClass,
|
|
type ApiModel,
|
|
ApiItemKind,
|
|
type ApiMethod,
|
|
type ApiPropertyItem,
|
|
} from '@microsoft/api-extractor-model';
|
|
import { DocItem } from './DocItem';
|
|
import { DocMethod } from './DocMethod';
|
|
import { DocProperty } from './DocProperty';
|
|
import { TypeParameterMixin } from './TypeParameterMixin';
|
|
import { type TokenDocumentation, genToken } from '~/util/parse.server';
|
|
|
|
export class DocClass extends TypeParameterMixin(DocItem<ApiClass>) {
|
|
public readonly extendsTokens: TokenDocumentation[] | null;
|
|
public readonly implementsTokens: TokenDocumentation[][];
|
|
public readonly methods: DocMethod[] = [];
|
|
public readonly properties: DocProperty[] = [];
|
|
|
|
public constructor(model: ApiModel, item: ApiClass) {
|
|
super(model, item);
|
|
const extendsExcerpt = item.extendsType?.excerpt;
|
|
|
|
this.extendsTokens = extendsExcerpt
|
|
? extendsExcerpt.spannedTokens.map((token) => genToken(this.model, token))
|
|
: null;
|
|
|
|
this.implementsTokens = item.implementsTypes.map((excerpt) =>
|
|
excerpt.excerpt.spannedTokens.map((token) => genToken(this.model, token)),
|
|
);
|
|
|
|
for (const member of item.members) {
|
|
switch (member.kind) {
|
|
case ApiItemKind.Method:
|
|
this.methods.push(new DocMethod(this.model, member as ApiMethod));
|
|
break;
|
|
case ApiItemKind.Property:
|
|
this.properties.push(new DocProperty(this.model, member as ApiPropertyItem));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override toJSON() {
|
|
return {
|
|
...super.toJSON(),
|
|
extendsTokens: this.extendsTokens,
|
|
implementsTokens: this.implementsTokens,
|
|
methods: this.methods.map((method) => method.toJSON()),
|
|
properties: this.properties.map((prop) => prop.toJSON()),
|
|
};
|
|
}
|
|
}
|