| 23 | public readonly externals = new Map<string, DocumentedExternal>(); |
| 24 | |
| 25 | public constructor( |
| 26 | data: DeclarationReflection[] | RootTypes[], |
| 27 | private readonly config: Config, |
| 28 | private readonly custom?: Record<string, CustomDocs>, |
| 29 | ) { |
| 30 | if (config.typescript) { |
| 31 | const items = data as DeclarationReflection[]; |
| 32 | |
| 33 | for (const item of items) { |
| 34 | switch (item.kindString) { |
| 35 | case 'Class': { |
| 36 | this.classes.set(item.name, new DocumentedClass(item, config)); |
| 37 | if (item.children) { |
| 38 | this.parse(item.children, item); |
| 39 | } |
| 40 | |
| 41 | break; |
| 42 | } |
| 43 | |
| 44 | case 'Function': { |
| 45 | this.functions.set(item.name, new DocumentedMethod(item, config)); |
| 46 | break; |
| 47 | } |
| 48 | |
| 49 | case 'Interface': |
| 50 | case 'Type alias': |
| 51 | case 'Enumeration': |
| 52 | this.typedefs.set(item.name, new DocumentedTypeDef(item, config)); |
| 53 | if (item.children) { |
| 54 | this.parse(item.children, item); |
| 55 | } |
| 56 | |
| 57 | break; |
| 58 | |
| 59 | default: |
| 60 | break; |
| 61 | } |
| 62 | } |
| 63 | } else { |
| 64 | let items = data as RootTypes[]; |
| 65 | items = items.filter((item) => !item.ignore); |
| 66 | |
| 67 | for (const item of items) { |
| 68 | switch (item.kind) { |
| 69 | case 'class': { |
| 70 | this.classes.set(item.name, new DocumentedClass(item, config)); |
| 71 | items = items.filter((otherItem) => otherItem.longname !== item.longname || otherItem.kind !== item.kind); |
| 72 | break; |
| 73 | } |
| 74 | |
| 75 | case 'function': { |
| 76 | if (item.scope === 'global' || !item.memberof) { |
| 77 | this.functions.set(item.name, new DocumentedMethod(item, config)); |
| 78 | items = items.filter((otherItem) => otherItem.longname !== item.longname); |
| 79 | } |
| 80 | |
| 81 | break; |
| 82 | } |