@@ -40,10 +40,19 @@ const ENTRY_POINTS = [
4040] ;
4141
4242// Run JSDoc for all entry points and build a global type registry for cross-file links
43- const results = ENTRY_POINTS . map ( entry => ( {
44- entry,
45- jsdoc : filterDocumented ( runJsDoc ( path . resolve ( ROOT_DIR , entry . source ) ) )
46- } ) ) ;
43+ const results = ENTRY_POINTS . map ( entry => {
44+
45+ let jsdoc = filterDocumented ( runJsDoc ( path . resolve ( ROOT_DIR , entry . source ) ) ) ;
46+ if ( entry . exclude ) {
47+
48+ const excludePath = path . resolve ( ROOT_DIR , entry . exclude ) ;
49+ jsdoc = jsdoc . filter ( d => ! d . meta || ! d . meta . path || ! d . meta . path . startsWith ( excludePath ) ) ;
50+
51+ }
52+
53+ return { entry, jsdoc } ;
54+
55+ } ) ;
4756
4857// Doclet type predicates
4958const isClass = d => d . kind === 'class' ;
@@ -69,7 +78,8 @@ for ( const { entry, jsdoc } of results ) {
6978
7079}
7180
72- // Pass 2: render each entry point.
81+ // Pass 2: render each entry point and accumulate sections per output file.
82+ const outputSections = { } ; // output file -> accumulated sections array
7383for ( const { entry, jsdoc } of results ) {
7484
7585 const resolveLink = name => {
@@ -173,7 +183,7 @@ for ( const { entry, jsdoc } of results ) {
173183
174184 }
175185
176- // construct the readme files
186+ // construct sections for this entry point
177187 const sections = [ `# ${ entry . title } ` , '' ] ;
178188
179189 for ( const [ groupName , consts ] of Object . entries ( constsByGroup ) ) {
@@ -207,23 +217,23 @@ for ( const { entry, jsdoc } of results ) {
207217
208218 }
209219
210- const header = '<!-- This file is generated automatically. Do not edit it directly. -->\n' ;
211- const output = header + resolveLinks ( sections . join ( '\n' ) ) ;
212- fs . writeFileSync ( path . join ( ROOT_DIR , entry . output ) , output ) ;
213- console . log ( `Written: ${ entry . output } ` ) ;
220+ if ( ! outputSections [ entry . output ] ) outputSections [ entry . output ] = [ ] ;
221+ outputSections [ entry . output ] . push ( ...sections ) ;
214222
215223}
216224
217- //
218-
219- function runJsDoc ( source ) {
225+ // Write each output file once, after all entry points have been processed.
226+ const header = '<!-- This file is generated automatically. Do not edit it directly. -->\n' ;
227+ for ( const [ outputFile , sections ] of Object . entries ( outputSections ) ) {
220228
221- // Default maxBuffer is 1 MB; large source directories can exceed that, so raise it to 32 MB.
222- const result = execSync ( `npx jsdoc -X -r " ${ source } "` , { maxBuffer : 32 * 1024 * 1024 } ) . toString ( ) ;
223- return JSON . parse ( result ) ;
229+ const output = header + resolveLinks ( sections . join ( '\n' ) ) ;
230+ fs . writeFileSync ( path . join ( ROOT_DIR , outputFile ) , output ) ;
231+ console . log ( `Written: ${ outputFile } ` ) ;
224232
225233}
226234
235+ //
236+
227237function groupByTag ( docs , predicate , defaultGroup ) {
228238
229239 const groups = { } ;
@@ -240,6 +250,14 @@ function groupByTag( docs, predicate, defaultGroup ) {
240250
241251}
242252
253+ function runJsDoc ( source ) {
254+
255+ // Default maxBuffer is 1 MB; large source directories can exceed that, so raise it to 32 MB.
256+ const result = execSync ( `npx jsdoc -X -r "${ source } "` , { maxBuffer : 32 * 1024 * 1024 } ) . toString ( ) ;
257+ return JSON . parse ( result ) ;
258+
259+ }
260+
243261// Topological sort: every parent class appears before its subclasses.
244262// Siblings (subclasses sharing the same parent) are kept together and ordered alphabetically.
245263function topologicalSortClasses ( classes ) {
0 commit comments