Skip to content

Commit

Permalink
Fix @categoryDescription, @groupDescription on modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Nov 27, 2024
1 parent 72b4054 commit c2c1289
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ title: Changelog
### Bug Fixes

- Fixed automatic discovery of entry points in packages mode.
- Fixed handling of `@categoryDescription` and `@groupDescription` on module pages, #2787.

## v0.27.0 (2024-11-27)

Expand Down
7 changes: 6 additions & 1 deletion src/lib/output/themes/default/partials/moduleReflection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function moduleReflection(context: DefaultThemeRenderContext, mod: Declar
</section>
)}

{sections.map(({ title, children }) => {
{sections.map(({ title, children, description }) => {
context.page.startNewSection(title);

return (
Expand All @@ -39,6 +39,11 @@ export function moduleReflection(context: DefaultThemeRenderContext, mod: Declar
{context.icons.chevronDown()} {title}
</h2>
</summary>
{description && (
<div class="tsd-comment tsd-typography">
<Raw html={context.markdown(description)} />
</div>
)}
<dl class="tsd-member-summaries">
{children.map((item) => context.moduleMemberSummary(item))}
</dl>
Expand Down
13 changes: 12 additions & 1 deletion src/lib/output/themes/lib.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { DefaultThemeRenderContext } from "../index.js";
import {
type CommentDisplayPart,
type ContainerReflection,
DeclarationReflection,
type DocumentReflection,
ProjectReflection,
ReferenceReflection,
type Reflection,
Expand Down Expand Up @@ -189,16 +191,23 @@ export function getHierarchyRoots(project: ProjectReflection): DeclarationReflec
return result;
}

export interface MemberSections {
title: string;
description?: CommentDisplayPart[];
children: Array<DocumentReflection | DeclarationReflection>;
}

export function getMemberSections(
parent: ContainerReflection,
childFilter: (refl: Reflection) => boolean = () => true,
) {
): MemberSections[] {
if (parent.categories?.length) {
return filterMap(parent.categories, (cat) => {
const children = cat.children.filter(childFilter);
if (!children.length) return;
return {
title: cat.title,
description: cat.description,
children,
};
});
Expand All @@ -212,6 +221,7 @@ export function getMemberSections(
if (!children.length) return;
return {
title: `${group.title} - ${cat.title}`,
description: cat.description,
children,
};
});
Expand All @@ -221,6 +231,7 @@ export function getMemberSections(
if (!children.length) return [];
return {
title: group.title,
description: group.description,
children,
};
});
Expand Down

0 comments on commit c2c1289

Please sign in to comment.