Skip to content

Commit

Permalink
fix: prepend "new" to constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKreil committed Dec 1, 2024
1 parent 6b90b56 commit a400020
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/commands/typedoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ function* documentMethod(method: DeclarationReflection, depth: number, isConstru

const [signature] = method.signatures;

const methodName = signature.name;
const parameters = formatMethodParameters(signature.parameters ?? []);
const returnType = signature.type;
const methodType = isConstructor ? 'Constructor' : 'Method';

yield `\n${'#'.repeat(depth)} ${methodType}: \`${methodName}(${parameters})\``;
if (isConstructor) {
yield `\n${'#'.repeat(depth)} Constructor: \`new ${signature.name}(${parameters})\``;
} else {
yield `\n${'#'.repeat(depth)} Method: \`${signature.name}(${parameters})\``;
}

yield* documentSummaryBlock(signature);

Expand All @@ -129,8 +129,8 @@ function* documentMethod(method: DeclarationReflection, depth: number, isConstru
}
}

if (returnType && !isConstructor) {
yield `\n**Returns:** <code>${formatTypeDeclaration(returnType)}</code>`;
if (signature.type && !isConstructor) {
yield `\n**Returns:** <code>${formatTypeDeclaration(signature.type)}</code>`;
}
}

Expand Down

0 comments on commit a400020

Please sign in to comment.