Skip to content

Commit 9e940df

Browse files
authored
Merge pull request #1577 from IgniteUI/ibarakov/fix-api-event-section-wc
fix: filter web components API event sections correctly
2 parents a09e437 + b9920aa commit 9e940df

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

packages/igniteui-mcp/igniteui-doc-mcp/src/lib/api-doc-search.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function extractSection(markdown: string, section: string): string | null
5959
const headingMap: Record<string, string[]> = {
6060
properties: ['properties', 'accessors'],
6161
methods: ['methods', 'functions'],
62-
events: ['events', 'outputs'],
62+
events: ['events', 'outputs', 'fires'],
6363
};
6464

6565
const headings = headingMap[section.toLowerCase()] || [];
@@ -68,8 +68,9 @@ export function extractSection(markdown: string, section: string): string | null
6868
}
6969

7070
const lines = markdown.split(/\r?\n/);
71-
let startIndex = -1;
72-
let endIndex = lines.length;
71+
const matches: string[] = [];
72+
let currentStart = -1;
73+
let currentHeading = '';
7374

7475
for (let index = 0; index < lines.length; index++) {
7576
const match = lines[index].match(/^##\s+(.+?)\s*$/);
@@ -79,20 +80,25 @@ export function extractSection(markdown: string, section: string): string | null
7980

8081
const normalizedHeading = match[1].toLowerCase().replace(/\s+/g, ' ').trim();
8182

82-
if (startIndex === -1) {
83-
if (headings.includes(normalizedHeading)) {
84-
startIndex = index;
85-
}
86-
continue;
83+
if (currentStart !== -1) {
84+
matches.push(lines.slice(currentStart, index).join('\n').trimEnd());
85+
currentStart = -1;
86+
currentHeading = '';
8787
}
8888

89-
endIndex = index;
90-
break;
89+
if (headings.includes(normalizedHeading)) {
90+
currentStart = index;
91+
currentHeading = normalizedHeading;
92+
}
93+
}
94+
95+
if (currentStart !== -1 && headings.includes(currentHeading)) {
96+
matches.push(lines.slice(currentStart).join('\n').trimEnd());
9197
}
9298

93-
if (startIndex === -1) {
99+
if (matches.length === 0) {
94100
return null;
95101
}
96102

97-
return lines.slice(startIndex, endIndex).join('\n').trimEnd();
103+
return matches.join('\n\n');
98104
}

0 commit comments

Comments
 (0)