Skip to content

Commit ac470a0

Browse files
committed
Filter unique methods for classes and interfaces
1 parent d31b26d commit ac470a0

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/scripts/parse/method.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { parseMethodArguments } from "./argument";
33
import { parseSentence } from "./comment";
44
import { resolveType } from "./variable";
55

6-
export const extractMethods = (page: Document, url?: string): Method[] => {
6+
export const parseMethods = (page: Document, url?: string): Method[] => {
77
const methods: Method[] = [];
88

99
const constructor = parseMethod(getConstructorDetailElement(page), url);
@@ -24,7 +24,7 @@ export const extractMethods = (page: Document, url?: string): Method[] => {
2424
}
2525
});
2626

27-
return methods;
27+
return methods.filter(filterUniqueMethods);
2828
}
2929

3030
const getConstructorDetailElement = (page: Document) => page.querySelector<HTMLElement>('#content>div.details>div.fixedFont');
@@ -95,6 +95,8 @@ const parseReturnValueComment = (returnValueDetailElement: HTMLElement) => {
9595
return null;
9696
}
9797

98+
const filterUniqueMethods = (method: Method, index: number, self: Array<Method>) => self.findIndex(m => m.name === method.name) === index;
99+
98100
const forEachContentElement = (page: Document, startHeader: string, callback: (element: HTMLElement) => any) => {
99101
const elements = getContentElements(page);
100102

@@ -112,4 +114,3 @@ const forEachContentElement = (page: Document, startHeader: string, callback: (e
112114
}
113115
}
114116
}
115-

src/scripts/parse/structure.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Class, Event, Interface } from "../types";
22
import { parseTypes } from "./argument";
33
import { parseSentence } from "./comment";
4-
import { extractMethods } from "./method";
4+
import { parseMethods } from "./method";
55
import { parseProperties } from "./property";
66

77
export const parseStructure = (doc: Document, url?: string): Class | Interface => {
8-
const methods = extractMethods(doc, url);
8+
const methods = parseMethods(doc, url);
99
const headerElement = doc.querySelector('#content>h1');
1010
const parsedName = parseName(headerElement?.textContent.trim().replace('Třída ', ''));
1111
const info = parseInfo(doc);
@@ -94,4 +94,4 @@ const parseEvents = (eventsElement: HTMLUListElement) => {
9494
return events;
9595
}
9696

97-
export const isInterface = (name: string) => Boolean(name.match(/(?:^|\.)I[A-Z][^.]*$/));
97+
export const isInterface = (name: string) => Boolean(name.match(/(?:^|\.)I[A-Z][^.]*$/));

0 commit comments

Comments
 (0)