1- import { copyFile , rm } from 'node:fs/promises' ;
1+ import { copyFile , readFile , rm } from 'node:fs/promises' ;
22import path from 'node:path' ;
33import { Application , type TypeDocOptions } from 'typedoc' ;
44import type { PluginOptions } from 'typedoc-plugin-markdown' ;
5+
6+ const root = path . resolve ( import . meta. dirname , '../../..' ) ;
7+
58console . log ( '📚 Generating reference...' ) ;
69
10+ const exportPaths = await discoverExports ( ) ;
11+ const allEntryPoints = exportPaths . map ( ( p ) => p . replaceAll ( '\\' , '/' ) ) ;
12+
713// Generate API documentation
8- await runTypedoc ( ) ;
14+ await runTypedoc ( allEntryPoints ) ;
915console . log ( '✅ Reference generated successfully!' ) ;
1016
1117await rm ( 'reference/index.md' , { force : true } ) ;
1218await copyFile ( '.vitepress/theme/components/api.index.md' , 'reference/index.md' ) ;
1319console . log ( '📚 New index added successfully' ) ;
1420
21+ async function discoverExports ( ) : Promise < string [ ] > {
22+ const excludedExports = new Set ( [ './experimental' , './parallelPlugin' ] ) ;
23+
24+ const pkgJsonPath = path . join ( root , 'packages/rolldown/package.json' ) ;
25+ const pkgJson : { exports : Record < string , { dev ?: string } > } = JSON . parse (
26+ await readFile ( pkgJsonPath , 'utf-8' ) ,
27+ ) ;
28+ return Object . entries ( pkgJson . exports ) . flatMap ( ( [ key , entry ] ) => {
29+ if ( excludedExports . has ( key ) || ! entry . dev ) return [ ] ;
30+ return path . join ( root , 'packages/rolldown' , entry . dev ) ;
31+ } ) ;
32+ }
33+
1534type TypedocVitepressThemeOptions = {
1635 docsRoot ?: string ;
1736 sidebar ?: any ;
@@ -20,20 +39,19 @@ type TypedocVitepressThemeOptions = {
2039/**
2140 * Run TypeDoc with the specified tsconfig
2241 */
23- async function runTypedoc ( ) : Promise < void > {
24- const root = path . resolve ( import . meta. dirname , '../../..' ) ;
25-
42+ async function runTypedoc ( entryPoints : string [ ] ) : Promise < void > {
2643 const options : TypeDocOptions & PluginOptions & TypedocVitepressThemeOptions = {
2744 tsconfig : path . join ( root , 'packages/rolldown/tsconfig.json' ) ,
2845 plugin : [
2946 'typedoc-plugin-markdown' ,
3047 'typedoc-vitepress-theme' ,
48+ 'typedoc-plugin-merge-modules' ,
3149 path . join ( import . meta. dirname , 'extract-options-plugin.ts' ) ,
3250 path . join ( import . meta. dirname , 'custom-theme-plugin.ts' ) ,
3351 ] ,
3452 theme : 'customTheme' ,
3553 out : './reference' ,
36- entryPoints : [ path . join ( root , 'packages/rolldown/src/index.ts' ) . replaceAll ( '\\' , '/' ) ] ,
54+ entryPoints,
3755 readme : 'none' ,
3856 excludeInternal : true ,
3957
0 commit comments