Skip to content

Commit

Permalink
fix: add inherited properties to search index (discordjs#10257)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qjuh authored May 6, 2024
1 parent 776880d commit e673b3c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/scripts/src/generateIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { generatePath } from '@discordjs/api-extractor-utils';
import { DocNodeKind } from '@microsoft/tsdoc';
import type { DocLinkTag, DocCodeSpan, DocNode, DocParagraph, DocPlainText } from '@microsoft/tsdoc';
import { resolveMembers } from './generateSplitDocumentation.js';
import { PACKAGES, fetchVersionDocs, fetchVersions } from './shared.js';

export interface MemberJSON {
Expand Down Expand Up @@ -117,25 +118,21 @@ export enum SearchOrderType {
export function visitNodes(item: ApiItem, tag: string) {
const members: (MemberJSON & { id: number })[] = [];

for (const member of item.members) {
if (!(member instanceof ApiDeclaredItem)) {
continue;
}

for (const { item: member, inherited } of ApiItemContainerMixin.isBaseClassOf(item)
? resolveMembers(item, (child): child is ApiDeclaredItem => child instanceof ApiDeclaredItem)
: []) {
if (member.kind === ApiItemKind.Constructor || member.kind === ApiItemKind.Namespace) {
continue;
}

if (ApiItemContainerMixin.isBaseClassOf(member)) {
members.push(...visitNodes(member, tag));
}
members.push(...visitNodes(member, tag));

members.push({
id: idx++,
name: member.displayName,
kind: member.kind,
summary: tryResolveSummaryText(member) ?? '',
path: generatePath(member.getHierarchy(), tag),
path: generatePath(inherited ? [...item.getHierarchy(), member] : member.getHierarchy(), tag),
type: SearchOrderType[member.kind as keyof typeof SearchOrderType],
});
}
Expand Down

0 comments on commit e673b3c

Please sign in to comment.