Skip to content

Commit d6b4a28

Browse files
committed
docs(reference): generate reference pages for APIs exposed from subpath exports (#8392)
Updated the reference generation script so that the reference pages for the APIs exposed from subpath exports are generated.
1 parent 8bd3cb8 commit d6b4a28

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

docs/.vitepress/scripts/generate-reference.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
1-
import { copyFile, rm } from 'node:fs/promises';
1+
import { copyFile, readFile, rm } from 'node:fs/promises';
22
import path from 'node:path';
33
import { Application, type TypeDocOptions } from 'typedoc';
44
import type { PluginOptions } from 'typedoc-plugin-markdown';
5+
6+
const root = path.resolve(import.meta.dirname, '../../..');
7+
58
console.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);
915
console.log('✅ Reference generated successfully!');
1016

1117
await rm('reference/index.md', { force: true });
1218
await copyFile('.vitepress/theme/components/api.index.md', 'reference/index.md');
1319
console.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+
1534
type 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

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"oxc-minify": "catalog:",
1919
"typedoc": "^0.28.14",
2020
"typedoc-plugin-markdown": "^4.9.0",
21+
"typedoc-plugin-merge-modules": "^7.0.0",
2122
"typedoc-vitepress-theme": "^1.1.2",
2223
"vitepress": "catalog:",
2324
"vitepress-plugin-group-icons": "catalog:",

knip.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
".vitepress/scripts/extract-options-plugin.ts", // used as a string path in TypeDoc plugin config
3030
".vitepress/scripts/custom-theme-plugin.ts", // used as a string path in TypeDoc plugin config
3131
],
32-
"ignoreDependencies": ["typedoc-vitepress-theme"],
32+
"ignoreDependencies": ["typedoc-plugin-merge-modules", "typedoc-vitepress-theme"],
3333
},
3434
"packages/bench": {
3535
"entry": ["vue-entry.js"],

pnpm-lock.yaml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)