diff --git a/apps/docs/components/docs/ComponentDocs.tsx b/apps/docs/components/docs/ComponentDocs.tsx index f27b5621..1562b447 100644 --- a/apps/docs/components/docs/ComponentDocs.tsx +++ b/apps/docs/components/docs/ComponentDocs.tsx @@ -45,10 +45,15 @@ export function ComponentParameters({ name }: ComponentDocsProps) { name: param.parameterName, description: comment?.tags?.find((tag) => tag.tag === 'param' && tag.name === param.parameterName)?.description, optional: param.isOptional, - type: member.excerptTokens.slice(param.parameterTypeTokenRange.startIndex, param.parameterTypeTokenRange.endIndex).map((t: any) => t.text).join(' '), + type: member.excerptTokens.slice(param.parameterTypeTokenRange.startIndex, param.parameterTypeTokenRange.endIndex).map((t: any) => t.text).join('') })); + const returnsComment = comment?.tags?.find((tag) => tag.tag === 'returns'); + const returnsType = member?.returnTypeTokenRange + ? member.excerptTokens.slice(member.returnTypeTokenRange.startIndex, member.returnTypeTokenRange.endIndex).map((t: any) => t.text).join('') + : undefined; + const returnsTypeValid = returnsType && returnsType !== 'void'; - if (!params?.length) { + if (!params?.length && !returnsTypeValid) { return (

No parameters

@@ -57,7 +62,7 @@ export function ComponentParameters({ name }: ComponentDocsProps) { }; return ( -
+
{params?.map((param: any) => (
@@ -73,6 +78,17 @@ export function ComponentParameters({ name }: ComponentDocsProps) {
))} + {returnsTypeValid && ( + <> +

{'=>'}

+
+ {returnsType && {returnsType}} +
+
+ {([returnsComment?.name, returnsComment?.description].filter(Boolean).join(' '))?.trim()} +
+ + )}
) }