docusaurus-plugin-typedoc 0.16.9 → 0.17.0
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/README.md +40 -19
- package/dist/options.js +2 -0
- package/dist/render.js +7 -0
- package/dist/theme.d.ts +4 -2
- package/dist/theme.js +13 -3
- package/dist/types.d.ts +3 -9
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = {
|
|
|
32
32
|
// Plugin / TypeDoc options
|
|
33
33
|
{
|
|
34
34
|
entryPoints: ['../src/index.ts'],
|
|
35
|
-
tsconfig: '../tsconfig.json'
|
|
35
|
+
tsconfig: '../tsconfig.json',
|
|
36
36
|
},
|
|
37
37
|
],
|
|
38
38
|
],
|
|
@@ -63,7 +63,6 @@ Once built the docs will be available at `/docs/api` (or equivalent out director
|
|
|
63
63
|
├──tsconfig.json
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
67
66
|
## Options
|
|
68
67
|
|
|
69
68
|
### TypeDoc options
|
|
@@ -80,7 +79,7 @@ tsconfig: '../tsconfig.json'
|
|
|
80
79
|
Additional TypeDoc plugins will need to be explicitly set:
|
|
81
80
|
|
|
82
81
|
```js
|
|
83
|
-
plugin:['typedoc-plugin-xyz']
|
|
82
|
+
plugin: ['typedoc-plugin-xyz'];
|
|
84
83
|
```
|
|
85
84
|
|
|
86
85
|
#### Other config options
|
|
@@ -96,18 +95,20 @@ TypeDoc options can also be declared:
|
|
|
96
95
|
|
|
97
96
|
Options specific to the plugin should also be declared in the same object.
|
|
98
97
|
|
|
99
|
-
| Name | Default | Description
|
|
100
|
-
| :---------------------- | :------ |
|
|
101
|
-
| `out` | `"api"` | Output dir relative to docs dir (use `.` for no subdir).
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `sidebar.
|
|
98
|
+
| Name | Default | Description |
|
|
99
|
+
| :---------------------- | :------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
100
|
+
| `out` | `"api"` | Output dir relative to docs dir (use `.` for no subdir). |
|
|
101
|
+
| `includeExtension` | `true` | Determines whether to preserve the `.md` extension in relative links. `true` is recommended as per [Docusaurus documentation](https://docusaurus.io/docs/docs-markdown-features#referencing-other-documents) |
|
|
102
|
+
| `frontmatter` | `null` | Additional frontmatter options object. See [Frontmatter](#frontmatter). |
|
|
103
|
+
| `sidebar.categoryLabel` | `API` | The sidebar parent category label. |
|
|
104
|
+
| `sidebar.fullNames` | `false` | Display full names with module path. |
|
|
105
|
+
| `sidebar.position` | `auto` | The position of the sidebar in the tree. |
|
|
106
|
+
| `sidebar.position` | `auto` | The position of the sidebar in the tree. |
|
|
105
107
|
|
|
106
108
|
### An example configuration
|
|
107
109
|
|
|
108
110
|
```js
|
|
109
111
|
module.exports = {
|
|
110
|
-
|
|
111
112
|
plugins: [
|
|
112
113
|
[
|
|
113
114
|
'docusaurus-plugin-typedoc',
|
|
@@ -115,14 +116,14 @@ module.exports = {
|
|
|
115
116
|
// TypeDoc options
|
|
116
117
|
entryPoints: ['../src/index.ts'],
|
|
117
118
|
tsconfig: '../tsconfig.json',
|
|
118
|
-
plugin:['typedoc-plugin-xyz'],
|
|
119
|
+
plugin: ['typedoc-plugin-xyz'],
|
|
119
120
|
|
|
120
121
|
// Plugin options
|
|
121
122
|
out: 'api-xyz',
|
|
122
123
|
sidebar: {
|
|
123
124
|
categoryLabel: 'API XYZ',
|
|
124
125
|
position: 0,
|
|
125
|
-
fullNames: true
|
|
126
|
+
fullNames: true,
|
|
126
127
|
},
|
|
127
128
|
},
|
|
128
129
|
],
|
|
@@ -130,7 +131,6 @@ module.exports = {
|
|
|
130
131
|
};
|
|
131
132
|
```
|
|
132
133
|
|
|
133
|
-
|
|
134
134
|
## Recipes
|
|
135
135
|
|
|
136
136
|
### Sidebar and Navbar
|
|
@@ -139,7 +139,7 @@ module.exports = {
|
|
|
139
139
|
|
|
140
140
|
`sidebars.js` can be configured in following ways:
|
|
141
141
|
|
|
142
|
-
1
|
|
142
|
+
1. Generate the entire sidebar from file structure of your docs folder (default behaviour):
|
|
143
143
|
|
|
144
144
|
```js
|
|
145
145
|
module.exports = {
|
|
@@ -152,7 +152,7 @@ module.exports = {
|
|
|
152
152
|
};
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
-
2
|
|
155
|
+
2. Alternatively, if you wish to manually control other parts of your sidebar you can use a slice for the TypeDoc sidebar.
|
|
156
156
|
|
|
157
157
|
> note: `sidebar.categoryLabel` and `sidebar.position` options are ignored with this implementation)
|
|
158
158
|
|
|
@@ -160,7 +160,7 @@ module.exports = {
|
|
|
160
160
|
module.exports = {
|
|
161
161
|
sidebar: {
|
|
162
162
|
'Category 1': ['doc1', 'doc2', 'doc3'],
|
|
163
|
-
|
|
163
|
+
API: [
|
|
164
164
|
{
|
|
165
165
|
type: 'autogenerated',
|
|
166
166
|
dirName: 'api', // 'api' is the 'out' directory
|
|
@@ -193,19 +193,40 @@ A navbar item can be configured in `themeConfig` options in `docusaurus.config.j
|
|
|
193
193
|
|
|
194
194
|
Please see https://docusaurus.io/docs/api/themes/configuration#navbar-items for navbar documentation.
|
|
195
195
|
|
|
196
|
+
### Frontmatter
|
|
197
|
+
|
|
198
|
+
By default the plugin will configure minimal required [Frontmatter](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs#markdown-front-matter) configuration.
|
|
199
|
+
Additionally required global Frontmatter options can be passed in using the `frontmatter` options object
|
|
200
|
+
|
|
201
|
+
`docusaurus.config.js`:
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
plugins: [
|
|
205
|
+
[
|
|
206
|
+
'docusaurus-plugin-typedoc',
|
|
207
|
+
{
|
|
208
|
+
// .... other plugin option
|
|
209
|
+
frontmatter: {
|
|
210
|
+
pagination_prev: null,
|
|
211
|
+
pagination_next: null
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
]
|
|
215
|
+
```
|
|
196
216
|
|
|
197
217
|
### Multi instance
|
|
198
218
|
|
|
199
219
|
It is possible to build multi TypeDoc instances by passing in multiple configs with unique ids:
|
|
200
220
|
|
|
201
221
|
`docusaurus.config.js`
|
|
222
|
+
|
|
202
223
|
```js
|
|
203
224
|
module.exports = {
|
|
204
225
|
plugins: [
|
|
205
226
|
[
|
|
206
227
|
'docusaurus-plugin-typedoc',
|
|
207
228
|
{
|
|
208
|
-
id:'api-1',
|
|
229
|
+
id: 'api-1',
|
|
209
230
|
entryPoints: ['../api-1/src/index.ts'],
|
|
210
231
|
tsconfig: '../api-1/tsconfig.json',
|
|
211
232
|
},
|
|
@@ -213,7 +234,7 @@ module.exports = {
|
|
|
213
234
|
[
|
|
214
235
|
'docusaurus-plugin-typedoc',
|
|
215
236
|
{
|
|
216
|
-
id:'api-2',
|
|
237
|
+
id: 'api-2',
|
|
217
238
|
entryPoints: ['../api-2/src/index.ts'],
|
|
218
239
|
tsconfig: '../api-2/tsconfig.json',
|
|
219
240
|
},
|
|
@@ -265,7 +286,7 @@ module.exports = {
|
|
|
265
286
|
entryPoints: ['../packages/package-a', '../packages/package-b'],
|
|
266
287
|
entryPointStrategy: 'packages',
|
|
267
288
|
sidebar: {
|
|
268
|
-
fullNames: true
|
|
289
|
+
fullNames: true,
|
|
269
290
|
},
|
|
270
291
|
},
|
|
271
292
|
],
|
package/dist/options.js
CHANGED
|
@@ -18,8 +18,10 @@ const DEFAULT_PLUGIN_OPTIONS = {
|
|
|
18
18
|
entryDocument: 'index.md',
|
|
19
19
|
plugin: ['none'],
|
|
20
20
|
watch: false,
|
|
21
|
+
includeExtension: true,
|
|
21
22
|
indexSlug: undefined,
|
|
22
23
|
theme: 'docusaurus',
|
|
24
|
+
frontmatter: undefined,
|
|
23
25
|
};
|
|
24
26
|
const getPluginOptions = (opts) => {
|
|
25
27
|
const options = {
|
package/dist/render.js
CHANGED
|
@@ -68,10 +68,17 @@ const addTypedocDeclarations = (app) => {
|
|
|
68
68
|
app.options.addDeclaration({
|
|
69
69
|
name: 'indexSlug',
|
|
70
70
|
});
|
|
71
|
+
app.options.addDeclaration({
|
|
72
|
+
name: 'includeExtension',
|
|
73
|
+
});
|
|
71
74
|
app.options.addDeclaration({
|
|
72
75
|
name: 'sidebar',
|
|
73
76
|
type: typedoc_1.ParameterType.Mixed,
|
|
74
77
|
});
|
|
78
|
+
app.options.addDeclaration({
|
|
79
|
+
name: 'frontmatter',
|
|
80
|
+
type: typedoc_1.ParameterType.Mixed,
|
|
81
|
+
});
|
|
75
82
|
};
|
|
76
83
|
function removeDir(path) {
|
|
77
84
|
if (fs.existsSync(path)) {
|
package/dist/theme.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { DeclarationReflection, PageEvent, ReflectionKind, Renderer, RendererEvent } from 'typedoc';
|
|
2
2
|
import { MarkdownTheme } from 'typedoc-plugin-markdown/dist/theme';
|
|
3
|
-
import { SidebarOptions } from './types';
|
|
3
|
+
import { FrontMatter, SidebarOptions } from './types';
|
|
4
4
|
export declare class DocusaurusTheme extends MarkdownTheme {
|
|
5
5
|
sidebar: SidebarOptions;
|
|
6
6
|
readmeTitle: string;
|
|
7
7
|
indexSlug: string;
|
|
8
|
+
includeExtension: string;
|
|
9
|
+
frontmatter: FrontMatter;
|
|
8
10
|
constructor(renderer: Renderer);
|
|
9
11
|
getRelativeUrl(url: string): string;
|
|
10
12
|
onPageEnd(page: PageEvent<DeclarationReflection>): void;
|
|
11
13
|
onRendererEnd(renderer: RendererEvent): void;
|
|
12
|
-
getYamlItems(page: PageEvent<DeclarationReflection>):
|
|
14
|
+
getYamlItems(page: PageEvent<DeclarationReflection>): FrontMatter;
|
|
13
15
|
getSidebarLabel(page: PageEvent<DeclarationReflection>): string | undefined;
|
|
14
16
|
getSidebarPosition(page: PageEvent<DeclarationReflection>): "0.5" | "0" | null;
|
|
15
17
|
getId(page: PageEvent): string;
|
package/dist/theme.js
CHANGED
|
@@ -52,9 +52,10 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
getRelativeUrl(url) {
|
|
55
|
-
const
|
|
55
|
+
const re = new RegExp(this.includeExtension === 'true' ? '' : '.md', 'g');
|
|
56
|
+
const relativeUrl = super.getRelativeUrl(url).replace(re, '');
|
|
56
57
|
if (path.basename(relativeUrl).startsWith('index')) {
|
|
57
|
-
return relativeUrl.replace('index', '');
|
|
58
|
+
return relativeUrl.replace('index', '').replace('.md', '');
|
|
58
59
|
}
|
|
59
60
|
return relativeUrl;
|
|
60
61
|
}
|
|
@@ -94,9 +95,12 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
|
|
|
94
95
|
if (page.url === page.project.url && this.entryPoints.length > 1) {
|
|
95
96
|
items = { ...items, hide_table_of_contents: true };
|
|
96
97
|
}
|
|
98
|
+
items = { ...items, custom_edit_url: null };
|
|
99
|
+
if (this.frontmatter) {
|
|
100
|
+
items = { ...items, ...this.frontmatter };
|
|
101
|
+
}
|
|
97
102
|
return {
|
|
98
103
|
...items,
|
|
99
|
-
custom_edit_url: null,
|
|
100
104
|
};
|
|
101
105
|
}
|
|
102
106
|
getSidebarLabel(page) {
|
|
@@ -167,6 +171,12 @@ __decorate([
|
|
|
167
171
|
__decorate([
|
|
168
172
|
(0, typedoc_1.BindOption)('indexSlug')
|
|
169
173
|
], DocusaurusTheme.prototype, "indexSlug", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
(0, typedoc_1.BindOption)('includeExtension')
|
|
176
|
+
], DocusaurusTheme.prototype, "includeExtension", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
(0, typedoc_1.BindOption)('frontmatter')
|
|
179
|
+
], DocusaurusTheme.prototype, "frontmatter", void 0);
|
|
170
180
|
exports.DocusaurusTheme = DocusaurusTheme;
|
|
171
181
|
const writeCategoryYaml = (categoryPath, label, position) => {
|
|
172
182
|
const yaml = [`label: "${label}"`];
|
package/dist/types.d.ts
CHANGED
|
@@ -14,18 +14,12 @@ export interface PluginOptions {
|
|
|
14
14
|
hideBreadcrumbs: boolean;
|
|
15
15
|
hidePageTitle: boolean;
|
|
16
16
|
entryDocument: string;
|
|
17
|
+
includeExtension?: boolean;
|
|
17
18
|
indexSlug?: string;
|
|
18
19
|
theme?: string;
|
|
20
|
+
frontmatter: FrontMatter;
|
|
19
21
|
}
|
|
20
|
-
export
|
|
21
|
-
id: string;
|
|
22
|
-
title: string;
|
|
23
|
-
slug?: string;
|
|
24
|
-
sidebar_label?: string;
|
|
25
|
-
sidebar_position?: number;
|
|
26
|
-
hide_title?: boolean;
|
|
27
|
-
hide_table_of_contents?: boolean;
|
|
28
|
-
}
|
|
22
|
+
export declare type FrontMatter = Record<string, string | boolean | number | null> | undefined;
|
|
29
23
|
export interface SidebarOptions {
|
|
30
24
|
fullNames?: boolean;
|
|
31
25
|
categoryLabel: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-typedoc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test:init": "rm -rf test/site && npx @docusaurus/init@latest init test/site classic",
|
|
31
31
|
"test:demo:start": "yarn run build && cd test/site && yarn run start",
|
|
32
32
|
"test:demo:build": "yarn run build && cd test/site && yarn run build && yarn run serve",
|
|
33
|
-
"test": "jest --colors"
|
|
33
|
+
"test": "jest --colors --updateSnapshot"
|
|
34
34
|
},
|
|
35
35
|
"author": "Thomas Grey",
|
|
36
36
|
"license": "MIT",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"typescript",
|
|
43
43
|
"api"
|
|
44
44
|
],
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "39b0da170611c2e27c821ef2f1869ff2e4bb0125"
|
|
46
46
|
}
|