0
# Plugin Bootstrap
1
2
Core plugin initialization that integrates with TypeDoc's application lifecycle, adding markdown output capabilities and comprehensive configuration options.
3
4
## Capabilities
5
6
### Load Function
7
8
The main plugin bootstrap function that integrates the plugin with TypeDoc's application system.
9
10
```typescript { .api }
11
/**
12
* The function that is called by TypeDoc to bootstrap the plugin.
13
* Exposes additional TypeDoc options and makes adjustments for markdown output.
14
* This method is not intended to be consumed in any other context than via the 'plugin' option.
15
* @param app - The TypeDoc Application instance
16
*/
17
function load(app: Application): void;
18
```
19
20
**Usage Example:**
21
22
```typescript
23
import { Application } from "typedoc";
24
import { load } from "typedoc-plugin-markdown";
25
26
// Initialize TypeDoc application
27
const app = new Application();
28
29
// Bootstrap the markdown plugin
30
load(app);
31
32
// The plugin is now loaded and ready to use
33
// Configure markdown output directory
34
app.options.setValue('markdown', './docs');
35
36
// Generate documentation
37
const project = app.converter.convert([
38
app.expandInputFiles(['src/**/*.ts'])
39
]);
40
41
if (project) {
42
await app.generateDocs(project, './docs');
43
}
44
```
45
46
### Plugin Integration Process
47
48
The `load()` function performs three main bootstrap operations:
49
50
1. **Options Registration**: Adds all plugin-specific configuration options to TypeDoc's options system
51
2. **Output Configuration**: Registers the 'markdown' output format and sets it as default
52
3. **System Setup**: Initializes the renderer and internationalization systems
53
54
**Core Integration Steps:**
55
56
```typescript
57
// 1. Bootstrap options - adds all plugin declarations
58
Object.entries(declarations).forEach(([name, declaration]) => {
59
app.options.addDeclaration({
60
name,
61
...declaration,
62
} as DeclarationOption);
63
});
64
65
// 2. Configure markdown outputs
66
app.outputs.addOutput('markdown', async (out, project) => {
67
await render(app.renderer as MarkdownRenderer, project, out);
68
});
69
70
app.outputs.setDefaultOutputName('markdown');
71
72
// 3. Setup renderer and translations
73
setupRenderer(app);
74
setupInternationalization(app);
75
```
76
77
### Option Declarations System
78
79
The plugin registers numerous configuration options through the declarations system.
80
81
```typescript { .api }
82
/**
83
* Plugin option declarations containing all configuration options
84
* with their types, defaults, and validation rules
85
*/
86
const declarations: Record<string, DeclarationOption>;
87
```
88
89
### Renderer Setup
90
91
Sets up the custom markdown renderer with enhanced capabilities.
92
93
```typescript { .api }
94
/**
95
* Sets up the custom markdown renderer with hooks and async job support
96
* @param app - The TypeDoc Application instance
97
*/
98
function setupRenderer(app: Application): void;
99
```
100
101
### Internationalization Setup
102
103
Configures internationalization support for the plugin.
104
105
```typescript { .api }
106
/**
107
* Sets up internationalization for the plugin with markdown-specific translations
108
* @param app - The TypeDoc Application instance
109
*/
110
function setupInternationalization(app: Application): void;
111
```
112
113
### Render Function
114
115
Core rendering function that processes TypeDoc projects into markdown documentation.
116
117
```typescript { .api }
118
/**
119
* Main render function that processes a TypeDoc project into markdown files
120
* @param renderer - The markdown renderer instance
121
* @param project - The TypeDoc project to render
122
* @param outputDirectory - The directory to write markdown files to
123
*/
124
async function render(
125
renderer: MarkdownRenderer,
126
project: ProjectReflection,
127
outputDirectory: string
128
): Promise<void>;
129
```
130
131
**Integration with TypeDoc CLI:**
132
133
```bash
134
# Using TypeDoc CLI with the plugin
135
typedoc --plugin typedoc-plugin-markdown --markdown ./docs src/**/*.ts
136
137
# Or using configuration file
138
typedoc --options typedoc.json
139
```
140
141
**TypeDoc Configuration Example:**
142
143
```json
144
{
145
"plugin": ["typedoc-plugin-markdown"],
146
"markdown": "./docs",
147
"entryPoints": ["src/**/*.ts"],
148
"fileExtension": ".md",
149
"hidePageHeader": true,
150
"useCodeBlocks": true
151
}
152
```