A TypeDoc theme that extends typedoc-plugin-markdown to generate Markdown compatible with VitePress.
npx @tessl/cli install tessl/npm-typedoc-vitepress-theme@1.1.0TypeDoc VitePress Theme is a specialized TypeDoc theme that extends typedoc-plugin-markdown to generate Markdown output specifically formatted for VitePress static site generators. It serves as a bridge between TypeDoc's API documentation generation capabilities and VitePress's Markdown-based documentation system, enabling developers to automatically generate comprehensive API documentation that seamlessly integrates with VitePress sites.
npm install typedoc-vitepress-themetypedoc-plugin-markdown >=4.4.0import { load } from "typedoc-vitepress-theme";For CommonJS:
const { load } = require("typedoc-vitepress-theme");import { MarkdownApplication } from "typedoc-plugin-markdown";
import { load } from "typedoc-vitepress-theme";
// Load the plugin into a TypeDoc application
const app = new MarkdownApplication();
load(app);
// Plugin automatically configures options and event handlers
// No additional setup requiredThe TypeDoc VitePress Theme is built around several key components:
load function that registers the theme with TypeDocMain entry point function that registers the theme with a TypeDoc markdown application instance.
/**
* Load the VitePress theme plugin into a TypeDoc markdown application
* @param app - TypeDoc markdown application instance
*/
function load(app: MarkdownApplication): void;Required Import:
import { MarkdownApplication } from "typedoc-plugin-markdown";The load function performs the following operations when called:
Registers Plugin Options: Adds configuration options for VitePress integration
docsRoot: Path to VitePress project root directorysidebar: Configuration for autogenerated VitePress sidebarSets Default Presets: Applies optimal TypeDoc settings for VitePress:
hidePageHeader: true - Removes page headers from generated markdownentryFileName: "index.md" - Uses index.md as entry file nameout: "./api" - Sets default output directoryConfigures Event Handlers: Sets up post-processing for VitePress compatibility:
Enables Sidebar Generation: Automatically generates sidebar configuration files:
typedoc-sidebar.json with navigation structureThe plugin defines the following TypeScript interfaces for configuration:
interface PluginOptions {
/**
* The path to the VitePress project root.
*/
docsRoot: string;
/**
* Configures the autogenerated VitePress sidebar.
*/
sidebar: Sidebar;
}
interface Sidebar {
/** Enable/disable automatic sidebar generation */
autoConfiguration: boolean;
/** Sidebar format - "vitepress", "vuepress1", or "vuepress2" */
format: string;
/** Pretty format the sidebar JSON output */
pretty: boolean;
/** Determines if sidebar items with children are collapsed by default */
collapsed: boolean;
}The plugin automatically registers the following TypeDoc options that can be configured in your typedoc.json:
Specifies the path to the VitePress project root directory. Required when TypeDoc runs from outside the VitePress project root.
{
"docsRoot": "./docs"
}Use Case Example:
├── package.json
├── typedoc.json # TypeDoc runs from here
└── docs/ # VitePress root (set as docsRoot)
├── .vitepress/
└── api/ # TypeDoc output directory
└── index.mdConfigures the autogenerated VitePress sidebar with the following properties:
autoConfiguration (boolean): Enable/disable automatic sidebar generation (default: true)format (string): Sidebar format - "vitepress", "vuepress1", or "vuepress2" (default: "vitepress")pretty (boolean): Pretty format the sidebar JSON output (default: false)collapsed (boolean): Determines if sidebar items with children are collapsed by default (default: true){
"sidebar": {
"autoConfiguration": true,
"format": "vitepress",
"pretty": true,
"collapsed": false
}
}{
"out": "./docs/api",
"docsRoot": "./docs"
}{
"out": "./docs/api",
"docsRoot": "./docs",
"sidebar": {
"autoConfiguration": true,
"format": "vitepress",
"pretty": true,
"collapsed": false
}
}For VuePress 2.x projects:
{
"out": "./docs/api",
"docsRoot": "./docs",
"sidebar": {
"autoConfiguration": true,
"format": "vuepress2",
"pretty": true,
"collapsed": true
}
}For VuePress 1.x projects:
{
"out": "./docs/api",
"docsRoot": "./docs",
"sidebar": {
"autoConfiguration": true,
"format": "vuepress1",
"pretty": true,
"collapsed": true
}
}When using the plugin, ensure your project structure accommodates the VitePress configuration:
├── package.json
├── typedoc.json
└── docs/
├── .vitepress/
└── api/ # Generated by TypeDoc
├── index.md
└── typedoc-sidebar.jsonThe plugin automatically generates:
typedoc-sidebar.json file containing navigation structureComplete example of using the plugin in a TypeDoc configuration:
{
"entryPoints": ["./src/index.ts"],
"out": "./docs/api",
"docsRoot": "./docs",
"plugin": ["typedoc-plugin-markdown", "typedoc-vitepress-theme"],
"sidebar": {
"autoConfiguration": true,
"format": "vitepress",
"pretty": true,
"collapsed": false
}
}To integrate the generated documentation into your VitePress site:
npm install typedoc-vitepress-themetypedoc.jsontypedoc-sidebar.json in your VitePress configurationExample VitePress config integration:
import sidebarConfig from './api/typedoc-sidebar.json';
export default {
themeConfig: {
sidebar: {
'/api/': sidebarConfig
}
}
}