@@ -2,12 +2,32 @@ import getConfig from '@doc-kit/core/utils/configuration/index.mjs';
22import { groupNodesByModule } from '@doc-kit/core/utils/generators.mjs' ;
33import { jsx , toJs } from 'estree-util-to-js' ;
44
5+ import { DOCUMENTATION_INDEX_TAG } from './constants.mjs' ;
6+ import { createJSXElement } from './utils/ast.mjs' ;
57import buildContent from './utils/buildContent.mjs' ;
6- import { injectDocumentationIndex } from './utils/documentationIndex.mjs' ;
78import { getSortedHeadNodes } from './utils/getSortedHeadNodes.mjs' ;
9+ import { JSX_IMPORTS } from '../html/constants.mjs' ;
810import { buildNotFoundPage } from './utils/synthetic/404.mjs' ;
911import { buildAllPage } from './utils/synthetic/all.mjs' ;
1012
13+ /**
14+ * Builds the `<DocumentationIndex />` element
15+ *
16+ * @param {Array<import('@doc-kit/core/generators/metadata/types').MetadataEntry> } moduleEntries
17+ */
18+ const buildDocumentationIndex = moduleEntries =>
19+ createJSXElement ( JSX_IMPORTS . DocumentationIndex . name , {
20+ inline : false ,
21+ entries : getSortedHeadNodes ( moduleEntries )
22+ . filter ( entry => entry . stability )
23+ . map ( ( { api, heading, stability } ) => ( {
24+ api,
25+ name : heading . data . name ,
26+ index : stability . data . index ,
27+ description : stability . data . description ,
28+ } ) ) ,
29+ } ) ;
30+
1131/**
1232 * Builds the `{ head, entries }` page descriptors for all configured synthetic
1333 * pages. The descriptors are cheap to build; the expensive `buildContent` step
@@ -60,13 +80,16 @@ export async function processChunk(slicedInput, itemIndices) {
6080 */
6181export async function * generate ( input , worker ) {
6282 // The `index` page is only generated when an `index` document is part of
63- // the input; the module list for the synthetic pages and the stability
64- // overview excludes it.
83+ // the input; the module list for the synthetic pages and the documentation
84+ // index excludes it.
6585 const moduleInput = input . filter ( entry => entry . api !== 'index' ) ;
6686
67- // Sections tagged with a `<!-- DOCUMENTATION_INDEX -->` comment (e.g. in
68- // the `index` document) receive the Stability Overview of all modules.
69- injectDocumentationIndex ( input , moduleInput ) ;
87+ // Sections tagged with a `<!-- DOCUMENTATION_INDEX -->` build an index
88+ for ( const entry of input ) {
89+ if ( entry . tags ?. includes ( DOCUMENTATION_INDEX_TAG ) ) {
90+ entry . content . children . push ( buildDocumentationIndex ( moduleInput ) ) ;
91+ }
92+ }
7093
7194 // Create sliced input: each item contains head + its module's entries
7295 // This avoids sending all 4700+ entries to every worker
0 commit comments