diff --git a/plugins/shared/titles.mjs b/plugins/shared/titles.mjs index e8920d4a..1ba9d6e2 100644 --- a/plugins/shared/titles.mjs +++ b/plugins/shared/titles.mjs @@ -107,11 +107,14 @@ export const getMemberPrefix = model => { return prefix ? `${prefix}: ` : ''; }; -export const getMemberTitle = (model, options) => { +export const getMemberTitle = (model, options, specificSignature = null) => { const prefix = getMemberPrefix(model); - const params = model.parameters ?? callableSignatures(model)[0]?.parameters; const name = escapeCode(memberName(model, options)); + const params = + specificSignature?.parameters ?? + model.parameters ?? + callableSignatures(model)[0]?.parameters; if (params) { return `${prefix}\`${escapeCode(signatureExpression(model, params, name))}\``; } diff --git a/plugins/theme/partials/index.mjs b/plugins/theme/partials/index.mjs index 543a9cba..e3cad8b6 100644 --- a/plugins/theme/partials/index.mjs +++ b/plugins/theme/partials/index.mjs @@ -73,6 +73,37 @@ export default ctx => { .join('\n'); }, + signatures(model, options) { + const md = []; + const multipleSignatures = + model.signatures && model.signatures?.length > 1; + + model.signatures?.forEach(signature => { + if (multipleSignatures) { + md.push( + heading( + options.headingLevel, + getMemberTitle( + model, + { local: isTypePage(ctx.page.model) }, + signature + ) + ) + ); + } + md.push( + ctx.partials.signature(signature, { + headingLevel: multipleSignatures + ? options.headingLevel + 1 + : options.headingLevel, + nested: options.nested, + multipleSignatures: false, + }) + ); + }); + return md.join('\n\n'); + }, + declaration(model, options) { const opts = { headingLevel: 2, nested: false, ...options }; const signatures = callableSignatures(model); @@ -181,6 +212,31 @@ export default ctx => { }); }, + memberContainer(model, options) { + const md = []; + + const isOverloadedMethod = + model.signatures && + model.signatures.length > 1 && + [ReflectionKind.Function, ReflectionKind.Method].includes(model.kind); + + if ( + !isOverloadedMethod && + !ctx.router.hasOwnDocument(model) && + model.kind !== ReflectionKind.Constructor + ) { + md.push(heading(options.headingLevel, ctx.partials.memberTitle(model))); + } + + md.push( + ctx.partials.member(model, { + headingLevel: options.headingLevel, + nested: options.nested, + }) + ); + return md.join('\n\n'); + }, + memberWithGroups(model, options) { const md = []; const stability = ctx.helpers.stabilityBlockquote(model.comment); @@ -260,7 +316,16 @@ export default ctx => { const multipleSignatures = model.signatures.length > 1; model.signatures.forEach(signature => { if (multipleSignatures) { - md.push(heading(options.headingLevel, i18n.kind_call_signature())); + md.push( + heading( + options.headingLevel, + getMemberTitle( + model, + { local: isTypePage(ctx.page.model) }, + signature + ) + ) + ); } md.push( ctx.partials.signature(signature, { diff --git a/tests/theme/theme.test.mjs.snapshot b/tests/theme/theme.test.mjs.snapshot index 36b5744c..4280cdec 100644 --- a/tests/theme/theme.test.mjs.snapshot +++ b/tests/theme/theme.test.mjs.snapshot @@ -119,22 +119,20 @@ Class demonstrating overload signatures. ### \`overloadMethod(name, count)\` -#### Call Signature - * \`name\` {string} A simple string parameter * \`count\` {number} A simple number parameter * Returns: {void} First overload signature. -#### Call Signature +### \`overloadMethod(isEnabled)\` * \`isEnabled\` {boolean} A simple boolean parameter * Returns: {string} Second overload signature. -#### Call Signature +### \`overloadMethod(id, isEnabled)\` * \`id\` {number} A simple string parameter * \`isEnabled\` {boolean} A simple boolean parameter