Skip to content

Commit

Permalink
Add special case for rendering @summary for functions
Browse files Browse the repository at this point in the history
Resolves #2803
  • Loading branch information
Gerrit0 committed Dec 8, 2024
1 parent b35cfd2 commit 88b8f2b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ title: Changelog
- Switch from gzip to deflate for compressing assets to make output consistent across different operating systems, #2796.
- `@include` and `@includeCode` now work for comments on the entry point for projects with a single entry point, #2800.
- Cascaded modifier tags will no longer be copied into type literals, #2802.
- `@summary` now works to describe functions within modules, #2803.

## v0.27.3 (2024-12-04)

Expand Down
3 changes: 3 additions & 0 deletions site/tags/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ If an `@summary` tag is not specified and `--useFirstParagraphOfCommentAsSummary
specified, TypeDoc will use the first paragraph of the comment as the short summary
to include on the modules page.

For overloaded functions, the `@summary` tag may be placed on the comment for the
first signature or on the comment for the function implementation.

## Example

```ts
Expand Down
4 changes: 4 additions & 0 deletions src/lib/output/themes/default/partials/comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export function commentShortSummary(context: DefaultThemeRenderContext, props: R
shortSummary = props.comment?.getShortSummary(context.options.getValue("useFirstParagraphOfCommentAsSummary"));
}

if (!shortSummary?.length && props.isDeclaration() && props.signatures?.length) {
return commentShortSummary(context, props.signatures[0]);
}

if (!shortSummary?.some((part) => part.text)) return;

return context.displayParts(shortSummary);
Expand Down

0 comments on commit 88b8f2b

Please sign in to comment.