Skip to content
Merged
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
30 changes: 24 additions & 6 deletions docs/.vitepress/scripts/generate-reference.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
import { copyFile, rm } from 'node:fs/promises';
import { copyFile, readFile, rm } from 'node:fs/promises';
import path from 'node:path';
import { Application, type TypeDocOptions } from 'typedoc';
import type { PluginOptions } from 'typedoc-plugin-markdown';

const root = path.resolve(import.meta.dirname, '../../..');

console.log('📚 Generating reference...');

const exportPaths = await discoverExports();
const allEntryPoints = exportPaths.map((p) => p.replaceAll('\\', '/'));

// Generate API documentation
await runTypedoc();
await runTypedoc(allEntryPoints);
console.log('✅ Reference generated successfully!');

await rm('reference/index.md', { force: true });
await copyFile('.vitepress/theme/components/api.index.md', 'reference/index.md');
console.log('📚 New index added successfully');

async function discoverExports(): Promise<string[]> {
const excludedExports = new Set(['./experimental', './parallelPlugin']);

const pkgJsonPath = path.join(root, 'packages/rolldown/package.json');
const pkgJson: { exports: Record<string, { dev?: string }> } = JSON.parse(
await readFile(pkgJsonPath, 'utf-8'),
);
return Object.entries(pkgJson.exports).flatMap(([key, entry]) => {
if (excludedExports.has(key) || !entry.dev) return [];
return path.join(root, 'packages/rolldown', entry.dev);
});
}

type TypedocVitepressThemeOptions = {
docsRoot?: string;
sidebar?: any;
Expand All @@ -20,20 +39,19 @@ type TypedocVitepressThemeOptions = {
/**
* Run TypeDoc with the specified tsconfig
*/
async function runTypedoc(): Promise<void> {
const root = path.resolve(import.meta.dirname, '../../..');

async function runTypedoc(entryPoints: string[]): Promise<void> {
const options: TypeDocOptions & PluginOptions & TypedocVitepressThemeOptions = {
tsconfig: path.join(root, 'packages/rolldown/tsconfig.json'),
plugin: [
'typedoc-plugin-markdown',
'typedoc-vitepress-theme',
'typedoc-plugin-merge-modules',
path.join(import.meta.dirname, 'extract-options-plugin.ts'),
path.join(import.meta.dirname, 'custom-theme-plugin.ts'),
],
theme: 'customTheme',
out: './reference',
entryPoints: [path.join(root, 'packages/rolldown/src/index.ts').replaceAll('\\', '/')],
entryPoints,
readme: 'none',
excludeInternal: true,

Expand Down
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"oxc-minify": "catalog:",
"typedoc": "^0.28.14",
"typedoc-plugin-markdown": "^4.9.0",
"typedoc-plugin-merge-modules": "^7.0.0",
"typedoc-vitepress-theme": "^1.1.2",
"vitepress": "catalog:",
"vitepress-plugin-group-icons": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion knip.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
".vitepress/scripts/extract-options-plugin.ts", // used as a string path in TypeDoc plugin config
".vitepress/scripts/custom-theme-plugin.ts", // used as a string path in TypeDoc plugin config
],
"ignoreDependencies": ["typedoc-vitepress-theme"],
"ignoreDependencies": ["typedoc-plugin-merge-modules", "typedoc-vitepress-theme"],
},
"packages/bench": {
"entry": ["vue-entry.js"],
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading