rspress-plugin-api-extractor
v0.1.1
Published
RSPress plugin for generating API documentation from TypeScript API Extractor models
Maintainers
Readme
rspress-plugin-api-extractor
An RSPress 2.0 plugin that generates interactive API documentation from Microsoft API Extractor models. Point it at your .api.json files and you get a documentation site: syntax-highlighted signatures, Twoslash hover tooltips, type references that cross-link between pages and copy-paste code examples.
Install
npm install rspress-plugin-api-extractor
# or
pnpm add rspress-plugin-api-extractorThe plugin is a peer of @rspress/core, react and react-dom; install those too if your site does not already have them.
Quick start
// rspress.config.ts
import { defineConfig } from "@rspress/core";
import { ApiExtractorPlugin } from "rspress-plugin-api-extractor";
export default defineConfig({
root: "docs",
plugins: [
ApiExtractorPlugin({
api: {
packageName: "my-library",
model: "./api/my-library.api.json",
},
}),
],
});npx rspress dev
# Generates one MDX page per public API item and serves them at http://localhost:3000The plugin reads your .api.json model and writes one MDX page per public API item under your docs root, grouped into category folders (classes, interfaces, functions, type aliases, enums, variables and namespaces) with navigation metadata. To produce the model, pair it with @savvy-web/rslib-builder, which emits the .api.json as part of your TypeScript build.
Features
- Generates API docs from
.api.jsonmodels for classes, interfaces, functions, type aliases, enums, variables and namespaces. - Type-checks code examples and adds Twoslash hover tooltips that show inferred types.
- Cross-links type references between pages, so a type named in a signature links to its own page.
- Drives single-package sites, multi-package portals, RSPress multiVersion and i18n from one plugin.
- Handles multi-entry-point packages: it deduplicates re-exports and notes which entry points each item is available from.
- Writes per-package
llms*.txtfiles and in-page actions for pointing an assistant at one package's docs.
Documentation
- Getting started — Install, minimal config, first build.
- Configuration — Full plugin-options reference.
- Config helpers —
fromFolderandfromModelsDirfor discovering config from package folders. - Single package — The single-API recipe.
- Multi-package — The multi-API portal recipe.
- Versioned — Documenting major versions side by side.
- i18n — Internationalized documentation.
- Multi-entry points — Deduplication, "Available from" and route collisions.
- LLMs — Per-package
llms*.txtfiles and assistant actions. - Runtime components — The runtime components and live
with-apicode blocks. - Troubleshooting — Route collisions, forgotten exports, Twoslash errors and stale caches.
