Skip to content

Comments

docs: generate api reference#6838

Closed
sxzz wants to merge 3 commits intomainfrom
docs/reference
Closed

docs: generate api reference#6838
sxzz wants to merge 3 commits intomainfrom
docs/reference

Conversation

@sxzz
Copy link
Member

@sxzz sxzz commented Nov 4, 2025

No description provided.

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 4, 2025

How to use the Graphite Merge Queue

Add the label graphite: merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@netlify
Copy link

netlify bot commented Nov 4, 2025

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit 856bbfa
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/691ec81c1456fa00087608eb
😎 Deploy Preview https://deploy-preview-6838--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@hyf0
Copy link
Member

hyf0 commented Nov 4, 2025

@copilot Why this PR deosn't trigger netlify preview CI?

This comment was marked as outdated.

@sxzz sxzz force-pushed the docs/reference branch 2 times, most recently from 188bb33 to 8420d58 Compare November 4, 2025 14:49
@sxzz
Copy link
Member Author

sxzz commented Nov 4, 2025

I squashed the commit and now triggered.

@hyf0
Copy link
Member

hyf0 commented Nov 4, 2025

For Bundler API, I think we should put well-organized content, but we currently don't have time to do it. So having something is better than having nothing.

Suggestions:

  • Still keep Bundler API page, but with a link that points to the reference page.
  • Put reference under the APIs sidebar with the name API Reference
    • For the name, I think API Reference is a good name. If it was me, I'll try to emphasize this page actually shows all API, so I will call it API Catelog under APIs.
  • I think we should keep config button in the nav bar, since it's the most frequent accessed content.

@hyf0 hyf0 requested a review from TheAlexLichter November 4, 2025 15:18
@hyf0
Copy link
Member

hyf0 commented Nov 4, 2025

Ah I see. You are gonna remove the options page. Let me add some context here.

@sxzz
Copy link
Member Author

sxzz commented Nov 4, 2025

  • Bundler API page is empty currently, so it's meaningless until someone can write a guidance, then we can have the page back.
  • We can rename Reference to API, and full name is API Reference (Vue docs also did)
  • Config on the navbar is weird, I think.

@hyf0
Copy link
Member

hyf0 commented Nov 4, 2025

Bundler API page is empty currently, so it's meaningless until someone can write a guidance, then we can have the page back.

Yes. We could do this.

We can rename Reference to API, and full name is API Reference (Vue docs also did)

Hmm. I think having a API item under the sidebar APIs is a bit of weird.

If you put it only in the nav bar. I think people will confuse about the relationship between API nav bar button and sidebar APIs area. I personally think that shows we don't think clearly about how to organize the content.

Config on the navbar is weird, I think.

This comes from vite's doc. https://vite.dev/config/

@sxzz
Copy link
Member Author

sxzz commented Nov 4, 2025

This is a bit different from Vite. Essentially, Config is just one item in the sidebar, whereas Vite dedicates several pages to explaining config in detail.

Also, I'm not sure what approach the Rolldown team wants to take for introducing config, whether we plan to provide both a reference and handwritten guidance, or choose just one style.

hyf0
hyf0 previously approved these changes Nov 4, 2025
Copy link
Member

@hyf0 hyf0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Sill let's see if there are opinions from @TheAlexLichter.

@sxzz sxzz marked this pull request as draft November 5, 2025 05:55
@sxzz sxzz marked this pull request as ready for review November 13, 2025 15:03
Copilot AI review requested due to automatic review settings November 13, 2025 15:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds automated API reference documentation generation using TypeDoc. The documentation is generated from TypeScript source files and integrated into the VitePress documentation site.

Key changes:

  • Added TypeDoc-based API reference generation with VitePress theme integration
  • Updated documentation navigation to link to generated reference pages instead of manual docs
  • Added pnpm trust policy exclusions for specific dependency versions

Reviewed Changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
package.json Updated packageManager to [email protected] and modified docs:build to include generation step
pnpm-workspace.yaml Added trustPolicyExclude entries for semver, chokidar, and rxjs
pnpm-lock.yaml Added TypeDoc dependencies and updated metadata (libc fields, version bumps)
knip.jsonc Added typedoc-vitepress-theme to ignoreDependencies for docs workspace
docs/package.json Added TypeDoc dependencies and generate script
docs/apis/bundler-api.md Removed placeholder documentation file
docs/apis/plugin-api.md Updated to reference new generated API documentation
docs/.vitepress/scripts/generate-reference.ts New script to generate API reference using TypeDoc
docs/.vitepress/config.ts Restructured sidebar to integrate generated TypeDoc documentation
.gitignore Added docs/reference to ignore generated documentation
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 12 to 43
await rm('reference/api/index.md', { force: true });
await rm('reference/api/_media', { recursive: true, force: true });

/**
* Run TypeDoc with the specified tsconfig
*/
async function runTypedoc(): Promise<void> {
const root = path.resolve(
import.meta.dirname,
'../../..',
);

const options: TypeDocOptions & PluginOptions = {
tsconfig: path.resolve(
root,
'packages/rolldown/tsconfig.json',
),
plugin: ['typedoc-plugin-markdown', 'typedoc-vitepress-theme'],
out: './reference',
entryPoints: [
path.resolve(root, 'packages/rolldown/src/index.ts'),
],
excludeInternal: true,

hideBreadcrumbs: true,
useCodeBlocks: true,
flattenOutputFiles: true,

// @ts-expect-error VitePress config
docsRoot: './reference',
};
const app = await Application.bootstrapWithPlugins(options);
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The out option is set to './reference', which is relative to the current working directory. Since this script is located in docs/.vitepress/scripts/, when executed, the current working directory will be docs/ (based on the package.json location).

However, the cleanup operations on lines 12-13 use paths like 'reference/api/index.md' which are also relative to the current working directory. This should work correctly, but it would be clearer and more robust to use path.resolve() consistently:

const docsRoot = path.resolve(import.meta.dirname, '../..');
await rm(path.resolve(docsRoot, 'reference/api/index.md'), { force: true });
await rm(path.resolve(docsRoot, 'reference/api/_media'), { recursive: true, force: true });

And update the options:

out: path.resolve(docsRoot, 'reference'),

Copilot uses AI. Check for mistakes.
Comment on lines +83 to +84
})).sort((a) => {
if (a.text === 'Functions') return -1;
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sort function has incorrect logic. Currently, it only returns -1 when a.text === 'Functions', but doesn't return a value for the else case. This means items that aren't "Functions" will have undefined as their sort value, which can lead to unpredictable sorting behavior.

The function should return 1 (or a positive number) for non-Functions items to ensure proper sorting:

})).sort((a) => {
  if (a.text === 'Functions') return -1;
  return 1;
});

Or use a proper comparator with both parameters:

})).sort((a, b) => {
  if (a.text === 'Functions') return -1;
  if (b.text === 'Functions') return 1;
  return 0;
});
Suggested change
})).sort((a) => {
if (a.text === 'Functions') return -1;
})).sort((a, b) => {
if (a.text === 'Functions') return -1;
if (b.text === 'Functions') return 1;

Copilot uses AI. Check for mistakes.
@hyf0 hyf0 dismissed their stale review November 13, 2025 15:07

Outdated.

Comment on lines +83 to +86
})).sort((a) => {
if (a.text === 'Functions') return -1;
return 0;
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sort comparison function is incorrect and will not sort properly. The sort() method requires a comparator function with two parameters (a, b), but only one parameter is provided.

// Current (broken)
}).sort((a) => {
  if (a.text === 'Functions') return -1;
  return 0;
});

// Fixed
}).sort((a, b) => {
  if (a.text === 'Functions') return -1;
  if (b.text === 'Functions') return 1;
  return 0;
});

Without comparing both elements, the sort will produce inconsistent results and may not place 'Functions' first as intended.

Suggested change
})).sort((a) => {
if (a.text === 'Functions') return -1;
return 0;
});
})).sort((a, b) => {
if (a.text === 'Functions') return -1;
if (b.text === 'Functions') return 1;
return 0;
});

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

console.log('📚 Beautifying reference structure...');

await rm('reference/api/index.md', { force: true });
await rm('reference/api/_media', { recursive: true, force: true });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is typedoc supposed to create a _media file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be necessary if there are external documents involved. For more information, see: https://typedoc.org/documents/External_Documents.html

I have removed this line.

Copilot AI review requested due to automatic review settings November 15, 2025 04:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +65 to +76
function getTypedocSidebar() {
const filepath = path.resolve(
import.meta.dirname,
'../reference/typedoc-sidebar.json',
);
if (!existsSync(filepath)) return [];

try {
return require(filepath) as DefaultTheme.SidebarItem[];
} catch (error) {
console.error('Failed to load typedoc sidebar:', error);
return [];
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider caching the TypeDoc sidebar to avoid loading it from the filesystem on every config access. Since VitePress config is evaluated multiple times during development, this could lead to unnecessary file system operations. You could use a let variable outside the function to cache the result.

Suggested change
function getTypedocSidebar() {
const filepath = path.resolve(
import.meta.dirname,
'../reference/typedoc-sidebar.json',
);
if (!existsSync(filepath)) return [];
try {
return require(filepath) as DefaultTheme.SidebarItem[];
} catch (error) {
console.error('Failed to load typedoc sidebar:', error);
return [];
let cachedTypedocSidebar: DefaultTheme.SidebarItem[] | undefined;
function getTypedocSidebar() {
if (cachedTypedocSidebar !== undefined) {
return cachedTypedocSidebar;
}
const filepath = path.resolve(
import.meta.dirname,
'../reference/typedoc-sidebar.json',
);
if (!existsSync(filepath)) {
cachedTypedocSidebar = [];
return cachedTypedocSidebar;
}
try {
cachedTypedocSidebar = require(filepath) as DefaultTheme.SidebarItem[];
return cachedTypedocSidebar;
} catch (error) {
console.error('Failed to load typedoc sidebar:', error);
cachedTypedocSidebar = [];
return cachedTypedocSidebar;

Copilot uses AI. Check for mistakes.
@sxzz sxzz closed this Jan 16, 2026
@sxzz sxzz deleted the docs/reference branch January 16, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants