fix(docgen): parsing constructor

This commit is contained in:
iCrawl
2022-06-09 11:37:22 +02:00
parent f2b267c079
commit 50822f5254
2 changed files with 22 additions and 8 deletions

View File

@@ -66,7 +66,7 @@ export class Documentation {
switch (item.kind) {
case 'class': {
this.classes.set(item.name, new DocumentedClass(item, config));
items = items.filter((i) => i.longname !== item.longname);
items = items.filter((i) => i.longname !== item.longname || i.kind !== item.kind);
break;
}
case 'function': {
@@ -153,11 +153,17 @@ export class Documentation {
path: dirname(member.sources?.[0]?.fileName ?? ''),
};
if (memberOf) info.push(`member of "${memberOf}"`);
if (meta) info.push(`${join(meta.path, meta.file ?? '')}${meta.line ? `:${meta.line}` : ''}`);
if (memberOf) {
info.push(`member of "${memberOf}"`);
}
if (meta) {
info.push(`${join(meta.path, meta.file ?? '')}${meta.line ? `:${meta.line}` : ''}`);
}
console.warn(`- "${name}"${info.length ? ` (${info.join(', ')})` : ''} has no accessible parent.`);
if (!name && !info.length) console.warn('Raw object:', member);
if (!name && !info.length) {
console.warn('Raw object:', member);
}
}
} else {
const it = items as ChildTypes[];
@@ -211,11 +217,17 @@ export class Documentation {
? null
: { file: member.meta.filename, line: member.meta.lineno, path: member.meta.path };
if (memberof) info.push(`member of "${memberof as string}"`);
if (meta) info.push(`${join(meta.path, meta.file)}${meta.line ? `:${meta.line}` : ''}`);
if (memberof) {
info.push(`member of "${memberof as string}"`);
}
if (meta) {
info.push(`${join(meta.path, meta.file)}${meta.line ? `:${meta.line}` : ''}`);
}
console.warn(`- "${name}"${info.length ? ` (${info.join(', ')})` : ''} has no accessible parent.`);
if (!name && !info.length) console.warn('Raw object:', member);
if (!name && !info.length) {
console.warn('Raw object:', member);
}
}
}
}

View File

@@ -52,7 +52,9 @@ export class DocumentedClass extends DocumentedItem<Class | DeclarationReflectio
public add(item: DocumentedConstructor | DocumentedMethod | DocumentedMember | DocumentedEvent) {
if (item instanceof DocumentedConstructor) {
if (this.construct) throw new Error(`Doc ${this.data.name} already has constructor`);
if (this.construct) {
throw new Error(`Doc ${this.data.name} already has constructor`);
}
this.construct = item;
} else if (item instanceof DocumentedMethod) {
// @ts-expect-error