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..e8e864c0 100644 --- a/plugins/theme/partials/index.mjs +++ b/plugins/theme/partials/index.mjs @@ -73,6 +73,51 @@ export default ctx => { .join('\n'); }, + signatures(model, options) { + const md = []; + const multipleSignatures = + model.signatures && model.signatures?.length > 1; + + if (model.comment && multipleSignatures) { + md.push( + ctx.partials.comment(model.comment, { + headingLevel: options.headingLevel + 1, + }) + ); + } + if (multipleSignatures && model.documents) { + md.push( + ctx.partials.documents(model, { + headingLevel: options.headingLevel + 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 +226,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 +330,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, {