MCPcopy
hub / github.com/discordjs/discord.js / parse

Method parse

packages/docgen/src/documentation.ts:111–253  ·  view source on GitHub ↗
(items: ChildTypes[] | DeclarationReflection[], prop?: DeclarationReflection)

Source from the content-addressed store, hash-verified

109 }
110
111 public parse(items: ChildTypes[] | DeclarationReflection[], prop?: DeclarationReflection) {
112 if (this.config.typescript) {
113 const it = items as DeclarationReflection[];
114
115 for (const member of it) {
116 let item: DocumentedConstructor | DocumentedEvent | DocumentedMember | DocumentedMethod | null = null;
117
118 switch (member.kindString) {
119 case 'Constructor': {
120 item = new DocumentedConstructor(member, this.config);
121 break;
122 }
123
124 case 'Method': {
125 const event = prop?.groups?.find((group) => group.title === 'Events');
126 if ((event?.children as unknown as number[])?.includes(member.id)) {
127 item = new DocumentedEvent(member, this.config);
128 break;
129 }
130
131 item = new DocumentedMethod(member, this.config);
132 break;
133 }
134
135 case 'Property': {
136 item = new DocumentedMember(member, this.config);
137 break;
138 }
139
140 default: {
141 console.warn(`- Unknown documentation kind "${member.kindString}" - \n${JSON.stringify(member)}\n`);
142 }
143 }
144
145 const parent = this.classes.get(prop!.name) ?? this.interfaces.get(prop!.name);
146 if (parent) {
147 if (item) {
148 parent.add(item);
149 } else {
150 console.warn(
151 `- Documentation item could not be constructed for "${member.name}" - \n${JSON.stringify(member)}\n`,
152 );
153 }
154
155 continue;
156 }
157
158 const info = [];
159 const name = (member.name || item?.data.name) ?? 'UNKNOWN';
160 const meta =
161 member.kindString === 'constructor'
162 ? null
163 : {
164 file: member.sources?.[0]?.fileName,
165 line: member.sources?.[0]?.line,
166 path: dirname(member.sources?.[0]?.fileName ?? ''),
167 };
168

Callers 15

constructorMethod · 0.95
index.tsFile · 0.80
setTitleMethod · 0.80
setCustomIdMethod · 0.80
setContextsMethod · 0.80
setIntegrationTypesMethod · 0.80
validateNameFunction · 0.80
validateTypeFunction · 0.80
validateDMPermissionFunction · 0.80

Calls 5

findMethod · 0.80
pushMethod · 0.80
getMethod · 0.45
addMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected