From a400020fe65b1c429fda372ecd894c3681a75ee8 Mon Sep 17 00:00:00 2001 From: Michael Kreil Date: Sun, 1 Dec 2024 14:54:50 +0100 Subject: [PATCH] fix: prepend "new" to constructors --- src/commands/typedoc.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/commands/typedoc.ts b/src/commands/typedoc.ts index 4ab4344..8a53c5a 100644 --- a/src/commands/typedoc.ts +++ b/src/commands/typedoc.ts @@ -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); @@ -129,8 +129,8 @@ function* documentMethod(method: DeclarationReflection, depth: number, isConstru } } - if (returnType && !isConstructor) { - yield `\n**Returns:** ${formatTypeDeclaration(returnType)}`; + if (signature.type && !isConstructor) { + yield `\n**Returns:** ${formatTypeDeclaration(signature.type)}`; } }