mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 17:43:30 +01:00
build: package api-extractor and -model (#9920)
* fix(ExceptText): don't display import("d..-types/v10"). in return type
* Squashed 'packages/api-extractor-model/' content from commit 39ecb196c
git-subtree-dir: packages/api-extractor-model
git-subtree-split: 39ecb196ca210bdf84ba6c9cadb1bb93571849d7
* Squashed 'packages/api-extractor/' content from commit 341ad6c51
git-subtree-dir: packages/api-extractor
git-subtree-split: 341ad6c51b01656d4f73b74ad4bdb3095f9262c4
* feat(api-extractor): add api-extractor and -model
* fix: package.json docs script
* fix(SourcLink): use <> instead of function syntax
* fix: make packages private
* fix: rest params showing in docs, added labels
* fix: missed two files
* fix: cpy-cli & pnpm-lock
* fix: increase icon size
* fix: icon size again
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { ApiItemKind } from '@microsoft/api-extractor-model';
|
||||
import { VscFileCode } from '@react-icons/all-files/vsc/VscFileCode';
|
||||
import { ApiItemKind } from '@discordjs/api-extractor-model';
|
||||
import { VscSymbolClass } from '@react-icons/all-files/vsc/VscSymbolClass';
|
||||
import { VscSymbolEnum } from '@react-icons/all-files/vsc/VscSymbolEnum';
|
||||
import { VscSymbolInterface } from '@react-icons/all-files/vsc/VscSymbolInterface';
|
||||
import { VscSymbolMethod } from '@react-icons/all-files/vsc/VscSymbolMethod';
|
||||
import { VscSymbolVariable } from '@react-icons/all-files/vsc/VscSymbolVariable';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
import { SourceLink } from './SourceLink';
|
||||
|
||||
function generateIcon(kind: ApiItemKind) {
|
||||
switch (kind) {
|
||||
@@ -30,7 +30,13 @@ export function Header({
|
||||
kind,
|
||||
name,
|
||||
sourceURL,
|
||||
}: PropsWithChildren<{ readonly kind: ApiItemKind; readonly name: string; readonly sourceURL?: string | undefined }>) {
|
||||
sourceLine,
|
||||
}: PropsWithChildren<{
|
||||
readonly kind: ApiItemKind;
|
||||
readonly name: string;
|
||||
readonly sourceLine?: number | undefined;
|
||||
readonly sourceURL?: string | undefined;
|
||||
}>) {
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<h2 className="flex flex-row place-items-center justify-between gap-2 break-all text-2xl font-bold">
|
||||
@@ -38,11 +44,7 @@ export function Header({
|
||||
<span>{generateIcon(kind)}</span>
|
||||
{name}
|
||||
</span>
|
||||
{sourceURL ? (
|
||||
<a className="text-blurple" href={sourceURL} rel="external noopener noreferrer" target="_blank">
|
||||
<VscFileCode />
|
||||
</a>
|
||||
) : null}
|
||||
{sourceURL ? <SourceLink sourceLine={sourceLine} sourceURL={sourceURL} /> : null}
|
||||
</h2>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ApiClass, ApiInterface, Excerpt } from '@microsoft/api-extractor-model';
|
||||
import { ApiItemKind } from '@microsoft/api-extractor-model';
|
||||
import type { ApiClass, ApiInterface, Excerpt } from '@discordjs/api-extractor-model';
|
||||
import { ApiItemKind } from '@discordjs/api-extractor-model';
|
||||
import { ExcerptText } from '../ExcerptText';
|
||||
|
||||
export function HierarchyText({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ApiDeclaredItem, ApiItemContainerMixin } from '@microsoft/api-extractor-model';
|
||||
import type { ApiDeclaredItem, ApiItemContainerMixin } from '@discordjs/api-extractor-model';
|
||||
import { MethodsSection } from './section/MethodsSection';
|
||||
import { PropertiesSection } from './section/PropertiesSection';
|
||||
import { hasProperties, hasMethods } from './util';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ApiDeclaredItem } from '@microsoft/api-extractor-model';
|
||||
import type { ApiDeclaredItem } from '@discordjs/api-extractor-model';
|
||||
import { SyntaxHighlighter } from '../SyntaxHighlighter';
|
||||
import { Header } from './Header';
|
||||
import { SummarySection } from './section/SummarySection';
|
||||
@@ -10,7 +10,12 @@ export interface ObjectHeaderProps {
|
||||
export function ObjectHeader({ item }: ObjectHeaderProps) {
|
||||
return (
|
||||
<>
|
||||
<Header kind={item.kind} name={item.displayName} sourceURL={item.sourceLocation.fileUrl} />
|
||||
<Header
|
||||
kind={item.kind}
|
||||
name={item.displayName}
|
||||
sourceURL={item.sourceLocation.fileUrl}
|
||||
sourceLine={item.sourceLocation.fileLine}
|
||||
/>
|
||||
{/* @ts-expect-error async component */}
|
||||
<SyntaxHighlighter code={item.excerpt.text} />
|
||||
<SummarySection item={item} />
|
||||
|
||||
22
apps/website/src/components/documentation/SourceLink.tsx
Normal file
22
apps/website/src/components/documentation/SourceLink.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { VscFileCode } from '@react-icons/all-files/vsc/VscFileCode';
|
||||
|
||||
export function SourceLink({
|
||||
className,
|
||||
sourceURL,
|
||||
sourceLine,
|
||||
}: {
|
||||
readonly className?: string | undefined;
|
||||
readonly sourceLine?: number | undefined;
|
||||
readonly sourceURL?: string | undefined;
|
||||
}) {
|
||||
return (
|
||||
<a
|
||||
className={` text-blurple ${className}`}
|
||||
href={sourceLine ? `${sourceURL}#L${sourceLine}` : sourceURL}
|
||||
rel="external noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
<VscFileCode />
|
||||
</a>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ApiConstructor } from '@microsoft/api-extractor-model';
|
||||
import type { ApiConstructor } from '@discordjs/api-extractor-model';
|
||||
import { VscSymbolMethod } from '@react-icons/all-files/vsc/VscSymbolMethod';
|
||||
import { CodeHeading } from '~/components/CodeHeading';
|
||||
import { ParameterTable } from '../../ParameterTable';
|
||||
@@ -10,7 +10,10 @@ export function ConstructorSection({ item }: { readonly item: ApiConstructor })
|
||||
return (
|
||||
<DocumentationSection icon={<VscSymbolMethod size={20} />} padded title="Constructor">
|
||||
<div className="flex flex-col gap-2">
|
||||
<CodeHeading>{`constructor(${parametersString(item)})`}</CodeHeading>
|
||||
<CodeHeading
|
||||
sourceURL={item.sourceLocation.fileUrl}
|
||||
sourceLine={item.sourceLocation.fileLine}
|
||||
>{`constructor(${parametersString(item)})`}</CodeHeading>
|
||||
{item.tsdocComment ? <TSDoc item={item} tsdoc={item.tsdocComment} /> : null}
|
||||
<ParameterTable item={item} />
|
||||
</div>
|
||||
|
||||
@@ -4,8 +4,8 @@ import type {
|
||||
ApiItemContainerMixin,
|
||||
ApiMethod,
|
||||
ApiMethodSignature,
|
||||
} from '@microsoft/api-extractor-model';
|
||||
import { ApiItemKind } from '@microsoft/api-extractor-model';
|
||||
} from '@discordjs/api-extractor-model';
|
||||
import { ApiItemKind } from '@discordjs/api-extractor-model';
|
||||
import { VscSymbolMethod } from '@react-icons/all-files/vsc/VscSymbolMethod';
|
||||
import { useMemo, Fragment } from 'react';
|
||||
import { resolveMembers } from '~/util/members';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ApiDocumentedItem, ApiParameterListMixin } from '@microsoft/api-extractor-model';
|
||||
import type { ApiDocumentedItem, ApiParameterListMixin } from '@discordjs/api-extractor-model';
|
||||
import { VscSymbolParameter } from '@react-icons/all-files/vsc/VscSymbolParameter';
|
||||
import { ParameterTable } from '../../ParameterTable';
|
||||
import { DocumentationSection } from './DocumentationSection';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ApiItemContainerMixin } from '@microsoft/api-extractor-model';
|
||||
import type { ApiItemContainerMixin } from '@discordjs/api-extractor-model';
|
||||
import { VscSymbolProperty } from '@react-icons/all-files/vsc/VscSymbolProperty';
|
||||
import { PropertyList } from '../../PropertyList';
|
||||
import { DocumentationSection } from './DocumentationSection';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ApiDeclaredItem } from '@microsoft/api-extractor-model';
|
||||
import type { ApiDeclaredItem } from '@discordjs/api-extractor-model';
|
||||
import { VscListSelection } from '@react-icons/all-files/vsc/VscListSelection';
|
||||
import { TSDoc } from '../tsdoc/TSDoc';
|
||||
import { DocumentationSection } from './DocumentationSection';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ApiTypeParameterListMixin } from '@microsoft/api-extractor-model';
|
||||
import type { ApiTypeParameterListMixin } from '@discordjs/api-extractor-model';
|
||||
import { VscSymbolParameter } from '@react-icons/all-files/vsc/VscSymbolParameter';
|
||||
import { TypeParamTable } from '../../TypeParamTable';
|
||||
import { DocumentationSection } from './DocumentationSection';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ApiItem } from '@microsoft/api-extractor-model';
|
||||
import type { ApiItem } from '@discordjs/api-extractor-model';
|
||||
import type { DocComment, DocFencedCode, DocLinkTag, DocNode, DocNodeContainer, DocPlainText } from '@microsoft/tsdoc';
|
||||
import { DocNodeKind, StandardTags } from '@microsoft/tsdoc';
|
||||
import type { Route } from 'next';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApiItemKind } from '@microsoft/api-extractor-model';
|
||||
import { ApiItemKind } from '@discordjs/api-extractor-model';
|
||||
import type {
|
||||
ApiItem,
|
||||
ApiItemContainerMixin,
|
||||
@@ -8,7 +8,7 @@ import type {
|
||||
ApiPropertySignature,
|
||||
ApiDocumentedItem,
|
||||
ApiParameterListMixin,
|
||||
} from '@microsoft/api-extractor-model';
|
||||
} from '@discordjs/api-extractor-model';
|
||||
import { METHOD_SEPARATOR, OVERLOAD_SEPARATOR } from '~/util/constants';
|
||||
import { resolveMembers } from '~/util/members';
|
||||
import { resolveParameters } from '~/util/model';
|
||||
@@ -63,9 +63,9 @@ export function serializeMembers(clazz: ApiItemContainerMixin): TableOfContentsS
|
||||
export function parametersString(item: ApiDocumentedItem & ApiParameterListMixin) {
|
||||
return resolveParameters(item).reduce((prev, cur, index) => {
|
||||
if (index === 0) {
|
||||
return `${prev}${cur.isOptional ? `${cur.name}?` : cur.name}`;
|
||||
return `${prev}${cur.isRest ? '...' : ''}${cur.isOptional ? `${cur.name}?` : cur.name}`;
|
||||
}
|
||||
|
||||
return `${prev}, ${cur.isOptional ? `${cur.name}?` : cur.name}`;
|
||||
return `${prev}, ${cur.isRest ? '...' : ''}${cur.isOptional ? `${cur.name}?` : cur.name}`;
|
||||
}, '');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user