mirror of
https://github.com/discordjs/discord.js.git
synced 2026-06-03 01:20:07 +00: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>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import type { ApiModel, ApiDeclaredItem } from '@microsoft/api-extractor-model';
|
|
import type { ReferenceData } from '~/model.server';
|
|
import { resolveName, genReference, resolveDocComment, TokenDocumentation, genToken } from '~/util/parse.server';
|
|
|
|
export type DocItemConstructor<T = DocItem> = new (...args: any[]) => T;
|
|
|
|
export class DocItem<T extends ApiDeclaredItem = ApiDeclaredItem> {
|
|
public readonly item: T;
|
|
public readonly name: string;
|
|
public readonly referenceData: ReferenceData;
|
|
public readonly summary: string | null;
|
|
public readonly model: ApiModel;
|
|
public readonly excerpt: string;
|
|
public readonly excerptTokens: TokenDocumentation[] = [];
|
|
public readonly kind: string;
|
|
|
|
public constructor(model: ApiModel, item: T) {
|
|
this.item = item;
|
|
this.kind = item.kind;
|
|
this.model = model;
|
|
this.name = resolveName(item);
|
|
this.referenceData = genReference(item);
|
|
this.summary = resolveDocComment(item);
|
|
this.excerpt = item.excerpt.text;
|
|
this.excerptTokens = item.excerpt.spannedTokens.map((token) => genToken(model, token));
|
|
}
|
|
|
|
public toJSON() {
|
|
return {
|
|
name: this.name,
|
|
referenceData: this.referenceData,
|
|
summary: this.summary,
|
|
excerpt: this.excerpt,
|
|
excerptTokens: this.excerptTokens,
|
|
kind: this.kind,
|
|
};
|
|
}
|
|
}
|