--- import { loadApi } from "../../api/model"; import { escapeHtml, inlineMarkdownHtml, returnsHtml, signatureHtml, typeHtml, } from "../../api/render"; import { Kind, type Reflection } from "../../api/types"; import ApiComment from "./ApiComment.astro"; type Props = { signature: Reflection; /** Name to show, e.g. the class name for constructors. */ name?: string; }; const api = loadApi(); const { signature: s, name } = Astro.props; const sig = signatureHtml(api, s, { name }); const params = (s.parameters ?? []).map((p) => ({ code: [ `${p.flags.isRest ? "..." : ""}${escapeHtml(p.name)}`, `${p.flags.isOptional || p.defaultValue !== undefined ? "?: " : ": "}`, typeHtml(api, p.type), p.defaultValue !== undefined ? ` = ${escapeHtml(p.defaultValue)}` : "", ].join(""), text: inlineMarkdownHtml(api, p.comment?.summary), })); const isCtor = s.kind === Kind.ConstructorSignature; const returns = returnsHtml(api, s.comment); // The signature already shows names, types and defaults. List parameters // and the return type only when they have docs. const showParams = params.some((p) => p.text); const showReturns = !isCtor && Boolean(returns); ---
{p.text && }