Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/toc-heading-depth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@doc-kit/generator-react': patch
---

fix: include depth-4 headings in the table of contents
4 changes: 3 additions & 1 deletion packages/react/src/jsx-ast/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const STABILITY_LEVELS = [
];

// How deep should the Table of Contents go?
export const TOC_MAX_HEADING_DEPTH = 3;
// Capped at 4 to match the MetaBar component, which only renders depth 2-4
// (many modules, e.g. diagnostics_channel, document class methods at depth 4)
export const TOC_MAX_HEADING_DEPTH = 4;

// 'Type: '.length
export const TYPE_PREFIX_LENGTH = 6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ describe('extractHeadings', () => {
);
});

it('includes headings up to depth 4 and drops deeper ones', () => {
const entries = [2, 3, 4, 5].map(depth => ({
heading: {
depth,
data: {
text: `heading ${depth}`,
name: `heading ${depth}`,
slug: `heading-${depth}`,
type: 'misc',
},
},
}));

const result = extractHeadings(entries);

assert.deepEqual(
result.map(({ depth }) => depth),
[2, 3, 4]
);
});

it('drops overload headings and links to the first signature', () => {
const entries = [
{
Expand Down
Loading