docusaurus-plugin-typedoc 1.0.0-next.22 → 1.0.0-next.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +7 -258
- package/dist/options.js +1 -0
- package/dist/plugin.d.ts +2 -3
- package/dist/plugin.js +10 -9
- package/dist/theme.d.ts +5 -0
- package/dist/theme.js +24 -0
- package/package.json +3 -3
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,270 +1,19 @@
|
|
|
1
1
|
# docusaurus-plugin-typedoc
|
|
2
2
|
|
|
3
|
-
 [  [](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml)
|
|
4
4
|
|
|
5
|
-
A
|
|
6
|
-
|
|
7
|
-
## Contents
|
|
8
|
-
|
|
9
|
-
- [What does it do?](#what-does-it-do)
|
|
10
|
-
- [Installation](#installation)
|
|
11
|
-
- [Usage](#usage)
|
|
12
|
-
- [Options](#options)
|
|
13
|
-
- [Sidebar](#sidebar)
|
|
14
|
-
- [Other configuration](#other-configuration)
|
|
15
|
-
- [License](#license)
|
|
16
|
-
|
|
17
|
-
## What does it do?
|
|
18
|
-
|
|
19
|
-
- Presets relevant options of [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/typedoc-plugin-markdown#readme).
|
|
20
|
-
- Runs TypeDoc from the Docusaurus CLI.
|
|
5
|
+
A Docusaurus plugin to integrate TypeDoc into a Docusaurus project.
|
|
21
6
|
|
|
22
7
|
## Installation
|
|
23
8
|
|
|
24
|
-
> Install [Docusaurus](https://v2.docusaurus.io/docs/installation) in the root of your project and install the plugin dependencies in the same location as the Docusaurus website directory.
|
|
25
|
-
|
|
26
|
-
> [typedoc](https://github.com/TypeStrong/typedoc) and [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown) are peer dependencies.
|
|
27
|
-
|
|
28
9
|
```shell
|
|
29
|
-
npm install docusaurus-plugin-typedoc
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
Add the plugin to `docusaurus.config.js` and specify the required options (see [options](#options)).
|
|
35
|
-
|
|
36
|
-
```js
|
|
37
|
-
module.exports = {
|
|
38
|
-
plugins: [
|
|
39
|
-
[
|
|
40
|
-
'docusaurus-plugin-typedoc',
|
|
41
|
-
|
|
42
|
-
// Plugin / TypeDoc options
|
|
43
|
-
{
|
|
44
|
-
entryPoints: ['../src/index.ts'],
|
|
45
|
-
tsconfig: '../tsconfig.json',
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
],
|
|
49
|
-
};
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
TypeDoc will be bootstraped with the Docusaurus `start` and `build` [cli commands](https://v2.docusaurus.io/docs/cli):
|
|
53
|
-
|
|
54
|
-
```javascript
|
|
55
|
-
"start": "docusaurus start",
|
|
56
|
-
"build": "docusaurus build",
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Once built the docs will be available at `http://localhost:3000/docs/api` (or equivalent out directory).
|
|
60
|
-
|
|
61
|
-
Typical directory structure:
|
|
62
|
-
|
|
63
|
-
├── docusaurus-website
|
|
64
|
-
├── build/ (static site dir)
|
|
65
|
-
├── docs/
|
|
66
|
-
│ ├── api/ (compiled typedoc markdown)
|
|
67
|
-
├── docusaurus.config.js
|
|
68
|
-
├── package.json
|
|
69
|
-
├── sidebars.js
|
|
70
|
-
├──package.json
|
|
71
|
-
├──src (typescript source files)
|
|
72
|
-
├──tsconfig.json
|
|
73
|
-
|
|
74
|
-
## Options
|
|
75
|
-
|
|
76
|
-
### TypeDoc options
|
|
77
|
-
|
|
78
|
-
Options can be declared:
|
|
79
|
-
|
|
80
|
-
- Passing arguments via the command line.
|
|
81
|
-
- Using a `typedoc.json` file.
|
|
82
|
-
- Under the `typedocOptions` key in `tsconfig.json`.
|
|
83
|
-
|
|
84
|
-
Please see <https://typedoc.org/options/configuration> for general TypeDoc option configuration.
|
|
85
|
-
|
|
86
|
-
The following TypeDoc / Markdown plugin options can be passed to config:
|
|
87
|
-
|
|
88
|
-
- [typedoc](https://typedoc.org/options) options (HTML specific output options that will be ignored).
|
|
89
|
-
- [typedoc-plugin-markdown ](https://github.com/tgreyuk/typedoc-plugin-markdown/tree/next/packages/typedoc-plugin-markdown#options) options (Some options are already preset to target Docusaurus).
|
|
90
|
-
|
|
91
|
-
The following typedoc-plugin-markdown options are preset with the plugin.
|
|
92
|
-
|
|
93
|
-
```json
|
|
94
|
-
{
|
|
95
|
-
"out": "./docs/api",
|
|
96
|
-
"hideInPageTOC": true,
|
|
97
|
-
"hideBreadcrumbs": true,
|
|
98
|
-
"hidePageHeader": true,
|
|
99
|
-
"entryFileName": "index.md"
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Plugin options
|
|
104
|
-
|
|
105
|
-
Options specific to the plugin should also be declared in the same object.
|
|
106
|
-
|
|
107
|
-
#### `--sidebar`
|
|
108
|
-
|
|
109
|
-
`sidebar.autoConfiguration`
|
|
110
|
-
|
|
111
|
-
Set to `false` to disable sidebar generation. Defaults to `true`.
|
|
112
|
-
|
|
113
|
-
`sidebar.filteredIds`
|
|
114
|
-
|
|
115
|
-
Ids of pages to be filtered from the sidebar. This would typically be used to filter README or index pages from the sidebar.
|
|
116
|
-
|
|
117
|
-
`sidebar.pretty`
|
|
118
|
-
|
|
119
|
-
Pretty format the sidebar JSON.
|
|
120
|
-
|
|
121
|
-
## Sidebar
|
|
122
|
-
|
|
123
|
-
> Previous versions of this plugin recommended an `autogenerated` sidebar configuration. However we have decided it is more deterministic and configurable to use a manual sidebar configuration with a generated sidebar file.
|
|
124
|
-
|
|
125
|
-
A docusaurus sidebar file `typedoc-sidebar.cjs` is published to the relevant output directory along with the generated markdown documentation.
|
|
126
|
-
|
|
127
|
-
This file should be referenced in `sidebars.js` using a sidebar slice and can be configured in following ways:
|
|
128
|
-
|
|
129
|
-
1. Display sidebar on the root:
|
|
130
|
-
|
|
131
|
-
```js
|
|
132
|
-
module.exports = {
|
|
133
|
-
typedocSidebar: require('./docs/api/typedoc-sidebar.cjs'),
|
|
134
|
-
};
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
2. Display the sidebar inside a category:
|
|
138
|
-
|
|
139
|
-
```js
|
|
140
|
-
module.exports = {
|
|
141
|
-
typedocSidebar: {
|
|
142
|
-
'Typedoc Docs': require('./docs/api/typedoc-sidebar.js'),
|
|
143
|
-
},
|
|
144
|
-
};
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
3. Display the sidebar inside a linked category
|
|
148
|
-
|
|
149
|
-
> Note the linked category page can be removed from sidebar using [`sidebar.filteredIds`]().
|
|
150
|
-
|
|
151
|
-
```js
|
|
152
|
-
module.exports = {
|
|
153
|
-
typedocSidebar: [
|
|
154
|
-
{
|
|
155
|
-
type: 'category',
|
|
156
|
-
label: 'Typedoc Docs',
|
|
157
|
-
link: {
|
|
158
|
-
type: 'doc',
|
|
159
|
-
id: 'api/index',
|
|
160
|
-
},
|
|
161
|
-
items: require('./docs/api/typedoc-sidebar.js'),
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
};
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Please see <https://docusaurus.io/docs/sidebar> for sidebar documentation.
|
|
168
|
-
|
|
169
|
-
## Other configuration
|
|
170
|
-
|
|
171
|
-
### Navbar
|
|
172
|
-
|
|
173
|
-
A navbar item can be configured in `themeConfig` options in `docusaurus.config.js`:
|
|
174
|
-
|
|
175
|
-
```js
|
|
176
|
-
themeConfig: {
|
|
177
|
-
navbar: {
|
|
178
|
-
items: [
|
|
179
|
-
{
|
|
180
|
-
to: 'docs/api/', // 'api' is the 'out' directory
|
|
181
|
-
activeBasePath: 'docs',
|
|
182
|
-
label: 'API',
|
|
183
|
-
position: 'left',
|
|
184
|
-
},
|
|
185
|
-
],
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
Please see <https://docusaurus.io/docs/api/themes/configuration#navbar-items> for navbar documentation.
|
|
191
|
-
|
|
192
|
-
### Multi instance
|
|
193
|
-
|
|
194
|
-
It is possible to build multi TypeDoc instances by passing in multiple configs with unique ids:
|
|
195
|
-
|
|
196
|
-
`docusaurus.config.js`
|
|
197
|
-
|
|
198
|
-
```js
|
|
199
|
-
module.exports = {
|
|
200
|
-
plugins: [
|
|
201
|
-
[
|
|
202
|
-
'docusaurus-plugin-typedoc',
|
|
203
|
-
{
|
|
204
|
-
id: 'api-1',
|
|
205
|
-
entryPoints: ['../api-1/src/index.ts'],
|
|
206
|
-
tsconfig: '../api-1/tsconfig.json',
|
|
207
|
-
out: 'api-1',
|
|
208
|
-
},
|
|
209
|
-
],
|
|
210
|
-
[
|
|
211
|
-
'docusaurus-plugin-typedoc',
|
|
212
|
-
{
|
|
213
|
-
id: 'api-2',
|
|
214
|
-
entryPoints: ['../api-2/src/index.ts'],
|
|
215
|
-
tsconfig: '../api-2/tsconfig.json',
|
|
216
|
-
out: 'api-2',
|
|
217
|
-
},
|
|
218
|
-
],
|
|
219
|
-
],
|
|
220
|
-
};
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
`sidebars.js`
|
|
224
|
-
|
|
225
|
-
```js
|
|
226
|
-
module.exports = {
|
|
227
|
-
typedocSidebar: {
|
|
228
|
-
'API 1': require('./docs/api-1/typedoc-sidebar.js'),
|
|
229
|
-
'API 2': require('./docs/api-2/typedoc-sidebar.js'),
|
|
230
|
-
},
|
|
231
|
-
};
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
### Watch mode
|
|
235
|
-
|
|
236
|
-
Watching files is supported by passing in the `watch: true` option see <https://typedoc.org/guides/options/#watch>.
|
|
237
|
-
|
|
238
|
-
Targetting the option in development mode only can be achieved using Node.js Environment Variables:
|
|
239
|
-
|
|
240
|
-
`package.json`
|
|
241
|
-
|
|
242
|
-
```json
|
|
243
|
-
"start": "TYPEDOC_WATCH=true docusaurus start",
|
|
244
|
-
"build": "TYPEDOC_WATCH=false docusaurus build",
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
`docusaurus.config.js`
|
|
248
|
-
|
|
249
|
-
```js
|
|
250
|
-
module.exports = {
|
|
251
|
-
plugins: [
|
|
252
|
-
[
|
|
253
|
-
'docusaurus-plugin-typedoc',
|
|
254
|
-
{
|
|
255
|
-
entryPoints: ['../src/index.ts'],
|
|
256
|
-
tsconfig: '../tsconfig.json',
|
|
257
|
-
watch: process.env.TYPEDOC_WATCH,
|
|
258
|
-
},
|
|
259
|
-
],
|
|
260
|
-
],
|
|
261
|
-
};
|
|
262
|
-
```
|
|
10
|
+
npm install docusaurus-plugin-typedoc --save-dev
|
|
11
|
+
```
|
|
263
12
|
|
|
264
|
-
|
|
13
|
+
## Documentation
|
|
265
14
|
|
|
266
|
-
|
|
15
|
+
Please visit https://typedoc-plugin-markdown.org/integrations/docusaurus.
|
|
267
16
|
|
|
268
17
|
## License
|
|
269
18
|
|
|
270
|
-
[MIT](
|
|
19
|
+
Released under the [MIT License](./LICENSE).
|
package/dist/options.js
CHANGED
package/dist/plugin.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { PluginOptions } from '.';
|
|
2
|
-
export default function pluginDocusaurus(context: any, opts: Partial<PluginOptions>): {
|
|
2
|
+
export default function pluginDocusaurus(context: any, opts: Partial<PluginOptions>): Promise<{
|
|
3
3
|
name: string;
|
|
4
|
-
loadContent(): Promise<void>;
|
|
5
4
|
extendCli(cli: any): void;
|
|
6
|
-
}
|
|
5
|
+
}>;
|
|
7
6
|
export declare function writeFileSync(fileName: string, data: string): void;
|
|
8
7
|
export declare function normalizePath(path: string): string;
|
|
9
8
|
export declare function removeDir(path: string): void;
|
package/dist/plugin.js
CHANGED
|
@@ -29,21 +29,21 @@ const path = __importStar(require("path"));
|
|
|
29
29
|
const typedoc_1 = require("typedoc");
|
|
30
30
|
const options_1 = require("./options");
|
|
31
31
|
const sidebar_1 = require("./sidebar");
|
|
32
|
+
const theme_1 = require("./theme");
|
|
32
33
|
// store list of plugin ids when running multiple instances
|
|
33
34
|
const apps = [];
|
|
34
|
-
function pluginDocusaurus(context, opts) {
|
|
35
|
+
async function pluginDocusaurus(context, opts) {
|
|
36
|
+
const PLUGIN_NAME = 'docusaurus-plugin-typedoc';
|
|
37
|
+
if (opts.id && !apps.includes(opts.id)) {
|
|
38
|
+
apps.push(opts.id);
|
|
39
|
+
await generateTypedoc(context, opts);
|
|
40
|
+
}
|
|
35
41
|
return {
|
|
36
|
-
name:
|
|
37
|
-
async loadContent() {
|
|
38
|
-
if (opts.id && !apps.includes(opts.id)) {
|
|
39
|
-
apps.push(opts.id);
|
|
40
|
-
await generateTypedoc(context, opts);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
42
|
+
name: PLUGIN_NAME,
|
|
43
43
|
extendCli(cli) {
|
|
44
44
|
cli
|
|
45
45
|
.command('generate-typedoc')
|
|
46
|
-
.description(
|
|
46
|
+
.description(`[${PLUGIN_NAME}] Generate TypeDoc docs independently of the Docusaurus build process.`)
|
|
47
47
|
.action(async () => {
|
|
48
48
|
var _a;
|
|
49
49
|
(_a = context.siteConfig) === null || _a === void 0 ? void 0 : _a.plugins.forEach((pluginConfig) => {
|
|
@@ -66,6 +66,7 @@ async function generateTypedoc(context, opts) {
|
|
|
66
66
|
const options = (0, options_1.getPluginOptions)(opts);
|
|
67
67
|
const { id, sidebar, ...optionsPassedToTypeDoc } = options;
|
|
68
68
|
const app = await typedoc_1.Application.bootstrapWithPlugins(optionsPassedToTypeDoc);
|
|
69
|
+
app.renderer.defineTheme('docusaurus', theme_1.DocusuaurusTheme);
|
|
69
70
|
const outputDir = app.options.getValue('out');
|
|
70
71
|
if (options.cleanOutputDir) {
|
|
71
72
|
removeDir(outputDir);
|
package/dist/theme.d.ts
ADDED
package/dist/theme.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocusuaurusTheme = void 0;
|
|
4
|
+
const typedoc_1 = require("typedoc");
|
|
5
|
+
const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
|
|
6
|
+
class DocusuaurusTheme extends typedoc_plugin_markdown_1.MarkdownTheme {
|
|
7
|
+
getRenderContext(pageEvent) {
|
|
8
|
+
return new DocusuaurusThemeThemeRenderContext(this, pageEvent, this.application.options);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.DocusuaurusTheme = DocusuaurusTheme;
|
|
12
|
+
class DocusuaurusThemeThemeRenderContext extends typedoc_plugin_markdown_1.MarkdownThemeRenderContext {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
// adds space around type arguments as docusaurus generates broken links without it in certain use-cases (see https://github.com/facebook/docusaurus/issues/9518)
|
|
16
|
+
this.typeArguments = (typeArguments) => {
|
|
17
|
+
return `\\< ${typeArguments
|
|
18
|
+
.map((typeArgument) => typeArgument instanceof typedoc_1.ReflectionType
|
|
19
|
+
? this.reflectionType(typeArgument)
|
|
20
|
+
: this.someType(typeArgument))
|
|
21
|
+
.join(', ')} \\>`;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-typedoc",
|
|
3
|
-
"version": "1.0.0-next.
|
|
4
|
-
"description": "A Docusaurus plugin to
|
|
3
|
+
"version": "1.0.0-next.24",
|
|
4
|
+
"description": "A Docusaurus plugin to integrate TypeDoc into a Docusaurus project.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist/"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"typedoc-plugin-markdown": ">=4.0.0-next.
|
|
19
|
+
"typedoc-plugin-markdown": ">=4.0.0-next.39"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"lint": "eslint ./src --ext .ts",
|