Skip to content

Commit 5ac59d8

Browse files
committed
Slightly improve docs for plugin creation
1 parent 6f59389 commit 5ac59d8

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

site/development/plugins.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ generally published as ESM to avoid `require(esm)` experimental warnings.
1818

1919
```js
2020
// @ts-check
21+
// npx typedoc --plugin ./plugin.js
22+
2123
import * as td from "typedoc";
2224
/** @param {td.Application} app */
2325
export function load(app) {
@@ -26,6 +28,26 @@ export function load(app) {
2628
}
2729
```
2830

31+
Plugin load functions may also be referenced directly in JS config files:
32+
33+
```js
34+
// typedoc.config.js
35+
import * as td from "typedoc";
36+
37+
/** @param {td.Application} app */
38+
export function customPlugin(app) {
39+
// Add event listeners to app, app.converter, etc.
40+
// this function may be async
41+
}
42+
43+
/** @type {td.TypeDocOptions} */
44+
const config = {
45+
plugin: [customPlugin],
46+
};
47+
48+
export default config;
49+
```
50+
2951
Plugins affect TypeDoc's execution by attaching event listeners to one or many
3052
events that will be fired during conversion and rendering. Events are available
3153
on the [Application], [Converter], [Renderer], and [Serializer]/[Deserializer]
@@ -44,8 +66,8 @@ Plugins which are configurable can add custom options with
4466
`app.options.addDeclaration`. [typedoc-plugin-mdn-links] has an example of the
4567
recommended way of doing this.
4668

47-
If you have specific questions regarding plugin development, please open an
48-
issue or ask in the [TypeScript Discord] #typedoc channel.
69+
If you have specific questions regarding plugin development, please create a
70+
discussion or ask in the [TypeScript Discord] #typedoc channel.
4971

5072
[typedoc-plugin-mdn-links]: https://github.com/Gerrit0/typedoc-plugin-mdn-links/blob/main/src/index.ts
5173
[TypeScript Discord]: https://discord.gg/typescript

0 commit comments

Comments
 (0)