TypeDoc Markdown Plugin
typedoc-plugin-markdown is a TypeDoc plugin that converts TypeScript API documentation into Markdown, making it compatible with static site generators like Docusaurus, VitePress, or GitHub Wikis. The current stable version, 4.11.0, reflects an active development approach with frequent minor and patch releases, ensuring ongoing enhancements and bug fixes. Its core function is to replace TypeDoc's default HTML theme with a built-in Markdown theme, offering extensive configuration options for various Markdown dialects and output structures. This plugin differentiates itself by providing fine-grained control over markdown generation, including custom routers for file organization, support for Prettier formatting, and options for dynamic content like navigation JSON. It is an essential tool for projects requiring documentation in a portable, text-based format.
Common errors
-
Error: Cannot find module 'typedoc-plugin-markdown'
cause The plugin package is not installed or TypeDoc cannot locate it based on the `plugins` configuration.fixRun `npm install typedoc typedoc-plugin-markdown --save-dev` to ensure the package is installed. Verify `typedoc-plugin-markdown` is correctly listed in your `typedoc.json` `plugins` array. -
TypeError: app.options.addReader is not a function
cause This usually indicates an incompatible version of TypeDoc is installed, leading to API mismatches with the plugin.fixCheck the `peerDependencies` of `typedoc-plugin-markdown` and install the exact `typedoc@0.28.x` version required (e.g., `npm install typedoc@0.28.x --save-dev`). -
Generated Markdown contains [object Object] or [Function] instead of expected type or value definitions.
cause TypeDoc or the plugin is failing to correctly resolve and render complex TypeScript types, especially for union types, intersection types, or function declarations returning functions.fixUpdate to `typedoc-plugin-markdown@4.11.0` or newer, which includes improved rendering for union types and function returns. Ensure your `tsconfig.json` used by TypeDoc correctly includes all relevant source files for complete type resolution. -
My markdownlint reports errors (e.g., empty table cells, invalid links) in the generated documentation.
cause Earlier versions of the plugin might have generated non-standard Markdown syntax or had issues with link fragment generation.fixUpgrade to `typedoc-plugin-markdown@4.10.0` or newer, as this version specifically includes fixes for common markdownlint errors related to tables and link fragments.
Warnings
- gotcha Peer Dependency Mismatch: This plugin requires a specific range of TypeDoc versions (e.g., `typedoc@0.28.x`). Using an incompatible TypeDoc version can lead to runtime errors, unexpected behavior, or TypeDoc loading multiple instances warnings.
- gotcha Configuration Options Placement: Plugin-specific options (e.g., `entryDocument`, `outputFileStrategy`) must be placed at the root level of your `typedoc.json` configuration, not inside `packageOptions`. Options inside `packageOptions` only apply to TypeDoc's conversion phase, whereas plugin options are applied during rendering.
- gotcha Markdown Rendering Inconsistencies (Older Versions): Early versions of `v4.x` could generate Markdown that caused `markdownlint` errors, contained invalid link fragments, or incorrectly handled specific TypeScript syntax (e.g., square brackets in index signatures, union type rendering).
- gotcha Advanced Customization Requires ESM: When writing local TypeDoc plugins or hooks that interact with `typedoc-plugin-markdown`, these custom plugins must be consumed as ECMAScript Modules (ESM) due to TypeDoc's modern architecture.
Install
-
npm install typedoc-plugin-markdown -
yarn add typedoc-plugin-markdown -
pnpm add typedoc-plugin-markdown
Imports
- plugins
import 'typedoc-plugin-markdown';
{ "plugins": ["typedoc-plugin-markdown"] } - MarkdownApplication
import * as TypedocMarkdown from 'typedoc-plugin-markdown';
import { MarkdownApplication } from 'typedoc-plugin-markdown'; - load
export function load(app: Application) { /* ... */ } // In a custom TypeDoc plugin file.
Quickstart
npm install typedoc@0.28.x typedoc-plugin-markdown --save-dev
// src/index.ts (example TypeScript file)
/**
* Represents a user profile.
* @interface
*/
export interface UserProfile {
/** The unique identifier for the user. */
id: string;
/** The user's full name. */
name: string;
/** The user's email address. */
email?: string;
/**
* Greets the user.
* @param greeting Custom greeting message.
* @returns A personalized greeting string.
*/
greet(greeting: string): string;
}
/**
* A utility class for user operations.
*/
export class UserUtilities {
/**
* Creates a new user profile.
* @param id The user ID.
* @param name The user name.
* @returns A new UserProfile instance.
*/
static createProfile(id: string, name: string): UserProfile {
return {
id,
name,
greet: (greeting: string) => `${greeting}, ${name}!`,
};
}
}
// typedoc.json
{
"entryPoints": [
"src/index.ts"
],
"out": "docs/api",
"plugin": [
"typedoc-plugin-markdown"
],
"entryDocument": "index.md",
"excludePrivate": true,
"excludeProtected": true,
"hideInPageTOC": true,
"outputFileStrategy": "modules"
}
# Run TypeDoc from your project root
npx typedoc