mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
feat(website): show inherited members (#8526)
* feat(website): show inherited members * fix: use passHref
This commit is contained in:
@@ -29,14 +29,29 @@ export class DocClass extends TypeParameterMixin(DocItem<ApiClass>) {
|
||||
excerpt.excerpt.spannedTokens.map((token) => genToken(this.model, token)),
|
||||
);
|
||||
|
||||
for (const member of item.members) {
|
||||
for (const member of item.findMembersWithInheritance().items) {
|
||||
switch (member.kind) {
|
||||
case ApiItemKind.Method:
|
||||
this.methods.push(new DocMethod(this.model, member as ApiMethod));
|
||||
case ApiItemKind.Method: {
|
||||
const method = member as ApiMethod;
|
||||
|
||||
if (method.parent?.containerKey !== this.containerKey) {
|
||||
this.methods.push(new DocMethod(this.model, method, true));
|
||||
break;
|
||||
}
|
||||
this.methods.push(new DocMethod(this.model, method));
|
||||
break;
|
||||
case ApiItemKind.Property:
|
||||
this.properties.push(new DocProperty(this.model, member as ApiPropertyItem));
|
||||
}
|
||||
case ApiItemKind.Property: {
|
||||
const property = member as ApiPropertyItem;
|
||||
|
||||
if (property.parent?.containerKey !== this.containerKey) {
|
||||
this.properties.push(new DocProperty(this.model, property, true));
|
||||
break;
|
||||
}
|
||||
|
||||
this.properties.push(new DocProperty(this.model, property));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,29 @@ export class DocInterface extends TypeParameterMixin(DocItem<ApiInterface>) {
|
||||
excerpt.excerpt.spannedTokens.map((token) => genToken(this.model, token)),
|
||||
);
|
||||
|
||||
for (const member of item.members) {
|
||||
for (const member of item.findMembersWithInheritance().items) {
|
||||
switch (member.kind) {
|
||||
case ApiItemKind.MethodSignature:
|
||||
this.methods.push(new DocMethodSignature(this.model, member as ApiMethodSignature));
|
||||
case ApiItemKind.MethodSignature: {
|
||||
const method = member as ApiMethodSignature;
|
||||
|
||||
if (method.parent?.containerKey !== this.containerKey) {
|
||||
this.methods.push(new DocMethodSignature(this.model, method, true));
|
||||
break;
|
||||
}
|
||||
this.methods.push(new DocMethodSignature(this.model, method));
|
||||
break;
|
||||
case ApiItemKind.PropertySignature:
|
||||
this.properties.push(new DocProperty(this.model, member as ApiPropertySignature));
|
||||
}
|
||||
case ApiItemKind.PropertySignature: {
|
||||
const property = member as ApiPropertySignature;
|
||||
|
||||
if (property.parent?.containerKey !== this.containerKey) {
|
||||
this.properties.push(new DocProperty(this.model, property, true));
|
||||
break;
|
||||
}
|
||||
|
||||
this.properties.push(new DocProperty(this.model, property));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,17 +1,31 @@
|
||||
import type { ApiMethod, ApiModel } from '@microsoft/api-extractor-model';
|
||||
import { DocFunction } from './DocFunction';
|
||||
import { Visibility } from './Visibility';
|
||||
import { generatePath } from '~/util/parse.server';
|
||||
|
||||
export interface InheritanceData {
|
||||
parentName: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export class DocMethod extends DocFunction {
|
||||
public readonly static: boolean;
|
||||
public readonly optional: boolean;
|
||||
public readonly visibility: Visibility;
|
||||
public readonly inheritanceData: InheritanceData | null;
|
||||
|
||||
public constructor(model: ApiModel, item: ApiMethod) {
|
||||
public constructor(model: ApiModel, item: ApiMethod, inherited = false) {
|
||||
super(model, item);
|
||||
this.static = item.isStatic;
|
||||
this.optional = item.isOptional;
|
||||
this.visibility = item.isProtected ? Visibility.Protected : Visibility.Public;
|
||||
this.inheritanceData =
|
||||
inherited && item.parent
|
||||
? {
|
||||
parentName: item.parent.displayName,
|
||||
path: generatePath(item.parent.getHierarchy()),
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
public override toJSON() {
|
||||
@@ -20,6 +34,7 @@ export class DocMethod extends DocFunction {
|
||||
static: this.static,
|
||||
optional: this.optional,
|
||||
visibility: this.visibility,
|
||||
inheritanceData: this.inheritanceData,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
import type { ApiMethodSignature, ApiModel } from '@microsoft/api-extractor-model';
|
||||
import { DocFunction } from './DocFunction';
|
||||
import type { InheritanceData } from './DocMethod';
|
||||
import { generatePath } from '~/util/parse.server';
|
||||
|
||||
export class DocMethodSignature extends DocFunction {
|
||||
public readonly optional: boolean;
|
||||
public readonly inheritanceData: InheritanceData | null;
|
||||
|
||||
public constructor(model: ApiModel, item: ApiMethodSignature) {
|
||||
public constructor(model: ApiModel, item: ApiMethodSignature, inherited = false) {
|
||||
super(model, item);
|
||||
this.optional = item.isOptional;
|
||||
this.inheritanceData =
|
||||
inherited && item.parent
|
||||
? {
|
||||
parentName: item.parent.displayName,
|
||||
path: generatePath(item.parent.getHierarchy()),
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
public override toJSON() {
|
||||
return {
|
||||
...super.toJSON(),
|
||||
optional: this.optional,
|
||||
inheritanceData: this.inheritanceData,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
import type { ApiPropertyItem, ApiModel, ApiPropertySignature } from '@microsoft/api-extractor-model';
|
||||
import { DocItem } from './DocItem';
|
||||
import { type TokenDocumentation, genToken } from '~/util/parse.server';
|
||||
import type { InheritanceData } from './DocMethod';
|
||||
import { type TokenDocumentation, genToken, generatePath } from '~/util/parse.server';
|
||||
|
||||
export class DocProperty extends DocItem<ApiPropertyItem> {
|
||||
public readonly propertyTypeTokens: TokenDocumentation[];
|
||||
public readonly readonly: boolean;
|
||||
public readonly optional: boolean;
|
||||
public readonly inheritanceData: InheritanceData | null;
|
||||
|
||||
public constructor(model: ApiModel, item: ApiPropertyItem | ApiPropertySignature) {
|
||||
public constructor(model: ApiModel, item: ApiPropertyItem | ApiPropertySignature, inherited = false) {
|
||||
super(model, item);
|
||||
this.propertyTypeTokens = item.propertyTypeExcerpt.spannedTokens.map((token) => genToken(this.model, token));
|
||||
this.readonly = item.isReadonly;
|
||||
this.optional = item.isOptional;
|
||||
this.inheritanceData =
|
||||
inherited && item.parent
|
||||
? {
|
||||
parentName: item.parent.displayName,
|
||||
path: generatePath(item.parent.getHierarchy()),
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
public override toJSON() {
|
||||
@@ -20,6 +29,7 @@ export class DocProperty extends DocItem<ApiPropertyItem> {
|
||||
propertyTypeTokens: this.propertyTypeTokens,
|
||||
readonly: this.readonly,
|
||||
optional: this.optional,
|
||||
inheritanceData: this.inheritanceData,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user