docusaurus-plugin-typedoc 1.0.0-next.14 → 1.0.0-next.16
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 +78 -103
- package/dist/options.d.ts +1 -1
- package/dist/options.js +10 -30
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.js +50 -7
- package/dist/sidebar.d.ts +2 -0
- package/dist/sidebar.js +32 -0
- package/package.json +7 -7
- package/dist/renderer.d.ts +0 -2
- package/dist/renderer.js +0 -66
package/README.md
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
# docusaurus-plugin-typedoc
|
|
2
2
|
|
|
3
|
+
 [](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml)
|
|
4
|
+
|
|
3
5
|
A [Docusaurus](https://v2.docusaurus.io/) plugin to build TypeScript API documentation with [TypeDoc](https://github.com/TypeStrong/typedoc).
|
|
4
6
|
|
|
5
|
-
|
|
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)
|
|
7
16
|
|
|
8
17
|
## What does it do?
|
|
9
18
|
|
|
10
19
|
- Presets relevant options of [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/typedoc-plugin-markdown#readme).
|
|
11
20
|
- Runs TypeDoc from the Docusaurus CLI.
|
|
12
|
-
- Adds some basic frontmatter to pages and exposes the ability to configure frontmatter further.
|
|
13
21
|
|
|
14
22
|
## Installation
|
|
15
23
|
|
|
16
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.
|
|
17
25
|
|
|
18
|
-
> [typedoc](https://github.com/TypeStrong/typedoc)
|
|
26
|
+
> [typedoc](https://github.com/TypeStrong/typedoc) and [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown) are peer dependencies.
|
|
19
27
|
|
|
20
28
|
```shell
|
|
21
29
|
npm install docusaurus-plugin-typedoc typedoc typedoc-plugin-markdown@next --save-dev
|
|
@@ -23,8 +31,6 @@ npm install docusaurus-plugin-typedoc typedoc typedoc-plugin-markdown@next --sav
|
|
|
23
31
|
|
|
24
32
|
## Usage
|
|
25
33
|
|
|
26
|
-
### Config
|
|
27
|
-
|
|
28
34
|
Add the plugin to `docusaurus.config.js` and specify the required options (see [options](#options)).
|
|
29
35
|
|
|
30
36
|
```js
|
|
@@ -50,34 +56,32 @@ TypeDoc will be bootstraped with the Docusaurus `start` and `build` [cli command
|
|
|
50
56
|
"build": "docusaurus build",
|
|
51
57
|
```
|
|
52
58
|
|
|
53
|
-
Once built the docs will be available at
|
|
59
|
+
Once built the docs will be available at `http://localhost:3000/docs/api` (or equivalent out directory).
|
|
54
60
|
|
|
55
|
-
|
|
61
|
+
Typical directory structure:
|
|
56
62
|
|
|
57
|
-
|
|
58
|
-
├──
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
├──
|
|
66
|
-
├──
|
|
67
|
-
├──tsconfig.json
|
|
68
|
-
```
|
|
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
|
|
69
73
|
|
|
70
74
|
## Options
|
|
71
75
|
|
|
76
|
+
### TypeDoc options
|
|
77
|
+
|
|
72
78
|
Options can be declared:
|
|
73
79
|
|
|
74
80
|
- Passing arguments via the command line.
|
|
75
81
|
- Using a `typedoc.json` file.
|
|
76
82
|
- Under the `typedocOptions` key in `tsconfig.json`.
|
|
77
83
|
|
|
78
|
-
Please see https://typedoc.org/options/configuration for general TypeDoc option configuration.
|
|
79
|
-
|
|
80
|
-
### TypeDoc options
|
|
84
|
+
Please see <https://typedoc.org/options/configuration> for general TypeDoc option configuration.
|
|
81
85
|
|
|
82
86
|
The following TypeDoc / Markdown plugin options can be passed to config:
|
|
83
87
|
|
|
@@ -92,8 +96,7 @@ The following typedoc-plugin-markdown options are preset with the plugin.
|
|
|
92
96
|
"hideInPageTOC": true,
|
|
93
97
|
"hideBreadcrumbs": true,
|
|
94
98
|
"hidePageHeader": true,
|
|
95
|
-
"entryFileName": "index.md"
|
|
96
|
-
"includeFileNumberPrefixes": true
|
|
99
|
+
"entryFileName": "index.md"
|
|
97
100
|
}
|
|
98
101
|
```
|
|
99
102
|
|
|
@@ -105,23 +108,15 @@ Options specific to the plugin should also be declared in the same object.
|
|
|
105
108
|
|
|
106
109
|
`sidebar.autoConfiguration`
|
|
107
110
|
|
|
108
|
-
Set to `false` to disable sidebar
|
|
109
|
-
|
|
110
|
-
`sidebar.categoryLabel`
|
|
111
|
-
|
|
112
|
-
The sidebar main parent category label. Defaults to entry page title.
|
|
113
|
-
|
|
114
|
-
`sidebar.readmeLabel`
|
|
111
|
+
Set to `false` to disable sidebar generation. Defaults to `true`.
|
|
115
112
|
|
|
116
|
-
|
|
113
|
+
`sidebar.filteredIds`
|
|
117
114
|
|
|
118
|
-
|
|
115
|
+
Ids of pages to be filtered from the sidebar. This would typically be used to filter README or modules named index from the sidebar.
|
|
119
116
|
|
|
120
|
-
|
|
117
|
+
`sidebar.pretty`
|
|
121
118
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
The position of the sidebar in the tree.
|
|
119
|
+
Pretty format the sidebar json
|
|
125
120
|
|
|
126
121
|
#### `--docsRoot`
|
|
127
122
|
|
|
@@ -131,92 +126,57 @@ The Docusaurus docs folder root. Use `./` if no root folder specified. Defaults
|
|
|
131
126
|
--docsRoot <path/to/docs-dir/>
|
|
132
127
|
```
|
|
133
128
|
|
|
134
|
-
|
|
129
|
+
## Sidebar
|
|
135
130
|
|
|
136
|
-
|
|
137
|
-
module.exports = {
|
|
138
|
-
plugins: [
|
|
139
|
-
[
|
|
140
|
-
'docusaurus-plugin-typedoc',
|
|
141
|
-
{
|
|
142
|
-
// TypeDoc options
|
|
143
|
-
entryPoints: ['../src/index.ts'],
|
|
144
|
-
tsconfig: '../tsconfig.json',
|
|
145
|
-
plugin: ['typedoc-plugin-xyz'],
|
|
131
|
+
> 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.
|
|
146
132
|
|
|
147
|
-
|
|
148
|
-
out: 'api-xyz',
|
|
149
|
-
},
|
|
150
|
-
],
|
|
151
|
-
],
|
|
152
|
-
};
|
|
153
|
-
```
|
|
133
|
+
A docusaurus sidebar file `typedoc-sidebar.cjs` is published to the relevant output directory along with the generated markdown documentation.
|
|
154
134
|
|
|
155
|
-
|
|
135
|
+
This file should be referenced in `sidebars.js` using a sidebar slice and can be configured in following ways:
|
|
156
136
|
|
|
157
|
-
|
|
137
|
+
1. Display sidebar on the root:
|
|
158
138
|
|
|
159
139
|
```js
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
## Frontmatter
|
|
164
|
-
|
|
165
|
-
Additional frontmatter options can be added to the config. Please see [typedoc-plugin-frontmatter](https://github.com/tgreyuk/typedoc-plugin-frontmatter#typedoc-plugin-frontmatter).
|
|
166
|
-
|
|
167
|
-
For example:
|
|
168
|
-
|
|
169
|
-
```json
|
|
170
|
-
{
|
|
171
|
-
"frontmatterGlobals": {
|
|
172
|
-
"pagination_prev": null,
|
|
173
|
-
"pagination_next": null
|
|
174
|
-
}
|
|
175
|
-
}
|
|
140
|
+
module.exports = {
|
|
141
|
+
typedocSidebar: require('./docs/api/typedoc-sidebar.cjs'),
|
|
142
|
+
};
|
|
176
143
|
```
|
|
177
144
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
### Sidebar and Navbar
|
|
181
|
-
|
|
182
|
-
#### Sidebar
|
|
183
|
-
|
|
184
|
-
`sidebars.js` can be configured in following ways:
|
|
185
|
-
|
|
186
|
-
1. Generate the entire sidebar from file structure of your docs folder (default behaviour):
|
|
145
|
+
2. Display the sidebar inside a category:
|
|
187
146
|
|
|
188
147
|
```js
|
|
189
148
|
module.exports = {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
dirName: '.', // '.' means the docs folder
|
|
194
|
-
},
|
|
195
|
-
],
|
|
149
|
+
typedocSidebar: {
|
|
150
|
+
'Typedoc Docs': require('./docs/api/typedoc-sidebar.cjs'),
|
|
151
|
+
},
|
|
196
152
|
};
|
|
197
153
|
```
|
|
198
154
|
|
|
199
|
-
|
|
155
|
+
3. Display the sidebar inside a linked category
|
|
200
156
|
|
|
201
|
-
>
|
|
157
|
+
> Note the linked category page can be removed from sidebar using [`sidebar.filteredIds`]().
|
|
202
158
|
|
|
203
159
|
```js
|
|
204
160
|
module.exports = {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
161
|
+
typedocSidebar: [
|
|
162
|
+
{
|
|
163
|
+
type: 'category',
|
|
164
|
+
label: 'Typedoc Docs',
|
|
165
|
+
link: {
|
|
166
|
+
type: 'doc',
|
|
167
|
+
id: 'api/index',
|
|
211
168
|
},
|
|
212
|
-
|
|
213
|
-
|
|
169
|
+
items: require('./docs/api/typedoc-sidebar.cjs'),
|
|
170
|
+
},
|
|
171
|
+
],
|
|
214
172
|
};
|
|
215
173
|
```
|
|
216
174
|
|
|
217
|
-
Please see https://docusaurus.io/docs/sidebar for sidebar documentation.
|
|
175
|
+
Please see <https://docusaurus.io/docs/sidebar> for sidebar documentation.
|
|
176
|
+
|
|
177
|
+
## Other configuration
|
|
218
178
|
|
|
219
|
-
|
|
179
|
+
### Navbar
|
|
220
180
|
|
|
221
181
|
A navbar item can be configured in `themeConfig` options in `docusaurus.config.js`:
|
|
222
182
|
|
|
@@ -235,7 +195,7 @@ A navbar item can be configured in `themeConfig` options in `docusaurus.config.j
|
|
|
235
195
|
},
|
|
236
196
|
```
|
|
237
197
|
|
|
238
|
-
Please see https://docusaurus.io/docs/api/themes/configuration#navbar-items for navbar documentation.
|
|
198
|
+
Please see <https://docusaurus.io/docs/api/themes/configuration#navbar-items> for navbar documentation.
|
|
239
199
|
|
|
240
200
|
### Multi instance
|
|
241
201
|
|
|
@@ -268,9 +228,20 @@ module.exports = {
|
|
|
268
228
|
};
|
|
269
229
|
```
|
|
270
230
|
|
|
231
|
+
`sidebars.js`
|
|
232
|
+
|
|
233
|
+
```js
|
|
234
|
+
module.exports = {
|
|
235
|
+
typedocSidebar: {
|
|
236
|
+
'API 1': require('./docs/api-1/typedoc-sidebar.cjs'),
|
|
237
|
+
'API 2': require('./docs/api-2/typedoc-sidebar.cjs'),
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
```
|
|
241
|
+
|
|
271
242
|
### Watch mode
|
|
272
243
|
|
|
273
|
-
Watching files is supported by passing in the `watch: true` option see
|
|
244
|
+
Watching files is supported by passing in the `watch: true` option see <https://typedoc.org/guides/options/#watch>.
|
|
274
245
|
|
|
275
246
|
Targetting the option in development mode only can be achieved using Node.js Environment Variables:
|
|
276
247
|
|
|
@@ -298,6 +269,10 @@ module.exports = {
|
|
|
298
269
|
};
|
|
299
270
|
```
|
|
300
271
|
|
|
272
|
+
### Frontmatter
|
|
273
|
+
|
|
274
|
+
To add frontmatter to page please use [typedoc-plugin-frontmatter](https://github.com/tgreyuk/typedoc-plugin-frontmatter#typedoc-plugin-frontmatter) and add options exposed by the plugin to the config.
|
|
275
|
+
|
|
301
276
|
## License
|
|
302
277
|
|
|
303
278
|
[MIT](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/docusaurus-plugin-typedoc/LICENSE)
|
package/dist/options.d.ts
CHANGED
package/dist/options.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const typedoc_1 = require("typedoc");
|
|
3
|
+
exports.setOptions = exports.getPluginOptions = void 0;
|
|
5
4
|
const DEFAULT_PLUGIN_OPTIONS = {
|
|
6
5
|
id: 'default',
|
|
7
6
|
docsRoot: 'docs',
|
|
@@ -9,12 +8,11 @@ const DEFAULT_PLUGIN_OPTIONS = {
|
|
|
9
8
|
hideInPageTOC: true,
|
|
10
9
|
hideBreadcrumbs: true,
|
|
11
10
|
hidePageHeader: true,
|
|
12
|
-
githubPages: false,
|
|
13
|
-
includeFileNumberPrefixes: true,
|
|
14
11
|
entryFileName: 'index.md',
|
|
15
12
|
sidebar: {
|
|
16
13
|
autoConfiguration: true,
|
|
17
14
|
},
|
|
15
|
+
plugin: ['typedoc-plugin-markdown'],
|
|
18
16
|
};
|
|
19
17
|
function getPluginOptions(opts) {
|
|
20
18
|
const options = {
|
|
@@ -24,34 +22,16 @@ function getPluginOptions(opts) {
|
|
|
24
22
|
...DEFAULT_PLUGIN_OPTIONS.sidebar,
|
|
25
23
|
...opts.sidebar,
|
|
26
24
|
},
|
|
25
|
+
plugin: [
|
|
26
|
+
...new Set([...DEFAULT_PLUGIN_OPTIONS.plugin, ...(opts.plugin || [])]),
|
|
27
|
+
],
|
|
27
28
|
};
|
|
28
29
|
return options;
|
|
29
30
|
}
|
|
30
31
|
exports.getPluginOptions = getPluginOptions;
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
app.options.addDeclaration({
|
|
36
|
-
name: 'sidebar',
|
|
37
|
-
type: typedoc_1.ParameterType.Mixed,
|
|
38
|
-
});
|
|
39
|
-
app.options.addReader(new (class {
|
|
40
|
-
constructor() {
|
|
41
|
-
this.name = 'docusaurus-options';
|
|
42
|
-
this.order = 900;
|
|
43
|
-
this.supportsPackages = false;
|
|
44
|
-
}
|
|
45
|
-
read(container) {
|
|
46
|
-
const requiredPlugins = [
|
|
47
|
-
'typedoc-plugin-markdown',
|
|
48
|
-
'typedoc-plugin-frontmatter',
|
|
49
|
-
];
|
|
50
|
-
const plugins = container.getValue('plugin');
|
|
51
|
-
container.setValue('plugin', [
|
|
52
|
-
...new Set([...requiredPlugins, ...plugins]),
|
|
53
|
-
]);
|
|
54
|
-
}
|
|
55
|
-
})());
|
|
32
|
+
function setOptions(app, options) {
|
|
33
|
+
for (const [key, val] of Object.entries(options)) {
|
|
34
|
+
app.options.setValue(key, val);
|
|
35
|
+
}
|
|
56
36
|
}
|
|
57
|
-
exports.
|
|
37
|
+
exports.setOptions = setOptions;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -4,3 +4,6 @@ export default function pluginDocusaurus(context: any, opts: Partial<PluginOptio
|
|
|
4
4
|
loadContent(): Promise<void>;
|
|
5
5
|
extendCli(cli: any): void;
|
|
6
6
|
};
|
|
7
|
+
export declare function writeFileSync(fileName: string, data: string): void;
|
|
8
|
+
export declare function normalizePath(path: string): string;
|
|
9
|
+
export declare function removeDir(path: string): void;
|
package/dist/plugin.js
CHANGED
|
@@ -23,10 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.removeDir = exports.normalizePath = exports.writeFileSync = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
26
28
|
const path = __importStar(require("path"));
|
|
27
29
|
const typedoc_1 = require("typedoc");
|
|
28
30
|
const options_1 = require("./options");
|
|
29
|
-
const
|
|
31
|
+
const sidebar_1 = require("./sidebar");
|
|
30
32
|
// store list of plugin ids when running multiple instances
|
|
31
33
|
const apps = [];
|
|
32
34
|
function pluginDocusaurus(context, opts) {
|
|
@@ -61,13 +63,25 @@ exports.default = pluginDocusaurus;
|
|
|
61
63
|
async function generateTypedoc(context, opts) {
|
|
62
64
|
const { siteDir } = context;
|
|
63
65
|
const options = (0, options_1.getPluginOptions)(opts);
|
|
64
|
-
const { id, docsRoot, ...optionsPassedToTypeDoc } = options;
|
|
66
|
+
const { id, docsRoot, sidebar, ...optionsPassedToTypeDoc } = options;
|
|
65
67
|
const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
await
|
|
70
|
-
|
|
68
|
+
if (options.cleanOutputDir) {
|
|
69
|
+
removeDir(outputDir);
|
|
70
|
+
}
|
|
71
|
+
const app = await typedoc_1.Application.bootstrapWithPlugins(optionsPassedToTypeDoc);
|
|
72
|
+
app.renderer.on(typedoc_1.PageEvent.END, (event) => {
|
|
73
|
+
var _a;
|
|
74
|
+
event.contents = (_a = event.contents) === null || _a === void 0 ? void 0 : _a.replace(/\\</g, '<');
|
|
75
|
+
});
|
|
76
|
+
app.renderer.postRenderAsyncJobs.push(async (output) => {
|
|
77
|
+
const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
|
|
78
|
+
const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, options.out);
|
|
79
|
+
fs.writeFileSync(sidebarPath, `// @ts-check
|
|
80
|
+
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
|
81
|
+
const typedocSidebar = { items: ${JSON.stringify(sidebarJson)}};
|
|
82
|
+
module.exports = typedocSidebar.items;`);
|
|
83
|
+
});
|
|
84
|
+
const project = await app.convert();
|
|
71
85
|
// if project is undefined typedoc has a problem - error logging will be supplied by typedoc.
|
|
72
86
|
if (!project) {
|
|
73
87
|
if (app.options.getValue('skipErrorChecking')) {
|
|
@@ -85,3 +99,32 @@ async function generateTypedoc(context, opts) {
|
|
|
85
99
|
await app.generateDocs(project, outputDir);
|
|
86
100
|
}
|
|
87
101
|
}
|
|
102
|
+
function writeFileSync(fileName, data) {
|
|
103
|
+
fs.mkdirSync(path.dirname(normalizePath(fileName)), { recursive: true });
|
|
104
|
+
fs.writeFileSync(normalizePath(fileName), data);
|
|
105
|
+
}
|
|
106
|
+
exports.writeFileSync = writeFileSync;
|
|
107
|
+
function normalizePath(path) {
|
|
108
|
+
return path.replace(/\\/g, '/');
|
|
109
|
+
}
|
|
110
|
+
exports.normalizePath = normalizePath;
|
|
111
|
+
function removeDir(path) {
|
|
112
|
+
if (fs.existsSync(path)) {
|
|
113
|
+
const files = fs.readdirSync(path);
|
|
114
|
+
if (files.length > 0) {
|
|
115
|
+
files.forEach(function (filename) {
|
|
116
|
+
if (fs.statSync(path + '/' + filename).isDirectory()) {
|
|
117
|
+
removeDir(path + '/' + filename);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
fs.unlinkSync(path + '/' + filename);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
fs.rmdirSync(path);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
fs.rmdirSync(path);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.removeDir = removeDir;
|
package/dist/sidebar.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSidebar = void 0;
|
|
4
|
+
function getSidebar(navigation, basePath) {
|
|
5
|
+
return navigation
|
|
6
|
+
.map((navigationItem) => {
|
|
7
|
+
return getNavigationItem(navigationItem, basePath);
|
|
8
|
+
})
|
|
9
|
+
.filter((navItem) => Boolean(navItem));
|
|
10
|
+
}
|
|
11
|
+
exports.getSidebar = getSidebar;
|
|
12
|
+
function getNavigationItem(navigationItem, basePath) {
|
|
13
|
+
var _a;
|
|
14
|
+
const id = navigationItem.url
|
|
15
|
+
? `${basePath}/${navigationItem.url}`.replace(/(.*).md/, '$1')
|
|
16
|
+
: null;
|
|
17
|
+
if ((_a = navigationItem.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
18
|
+
return {
|
|
19
|
+
type: 'category',
|
|
20
|
+
label: navigationItem.title,
|
|
21
|
+
items: getSidebar(navigationItem.children, basePath),
|
|
22
|
+
...(id && { link: { type: 'doc', id } }),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return id
|
|
26
|
+
? {
|
|
27
|
+
type: 'doc',
|
|
28
|
+
id,
|
|
29
|
+
label: navigationItem.title,
|
|
30
|
+
}
|
|
31
|
+
: null;
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-typedoc",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.16",
|
|
4
4
|
"description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,17 +15,14 @@
|
|
|
15
15
|
"directory": "packages/docusaurus-plugin-typedoc"
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"typedoc-plugin-frontmatter": ">=0.0.2"
|
|
20
|
-
},
|
|
21
18
|
"peerDependencies": {
|
|
22
|
-
"typedoc-plugin-markdown": ">=4.0.0-next.
|
|
19
|
+
"typedoc-plugin-markdown": ">=4.0.0-next.21"
|
|
23
20
|
},
|
|
24
21
|
"scripts": {
|
|
25
22
|
"lint": "eslint ./src --ext .ts",
|
|
26
23
|
"prepublishOnly": "npm run lint && npm run build",
|
|
27
24
|
"build": "rm -rf ./dist && tsc",
|
|
28
|
-
"
|
|
25
|
+
"task:docs": "node ./tasks/docs.mjs"
|
|
29
26
|
},
|
|
30
27
|
"author": "Thomas Grey",
|
|
31
28
|
"license": "MIT",
|
|
@@ -36,5 +33,8 @@
|
|
|
36
33
|
"markdown",
|
|
37
34
|
"typescript",
|
|
38
35
|
"api"
|
|
39
|
-
]
|
|
36
|
+
],
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@docusaurus/types": "^2.4.1"
|
|
39
|
+
}
|
|
40
40
|
}
|
package/dist/renderer.d.ts
DELETED
package/dist/renderer.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadRenderer = void 0;
|
|
4
|
-
const typedoc_plugin_frontmatter_1 = require("typedoc-plugin-frontmatter");
|
|
5
|
-
function loadRenderer(app) {
|
|
6
|
-
app.renderer.on(typedoc_plugin_frontmatter_1.FrontmatterEvent.PREPARE_FRONTMATTER, (event) => {
|
|
7
|
-
loadFrontmatter(app, event);
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
exports.loadRenderer = loadRenderer;
|
|
11
|
-
function loadFrontmatter(app, event) {
|
|
12
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
13
|
-
const hasReadme = !app.options.getValue('readme').endsWith('none');
|
|
14
|
-
const entryPage = app.options.getValue('entryFileName');
|
|
15
|
-
const indexPage = app.options.getValue('indexFileName');
|
|
16
|
-
const sidebar = app.options.getValue('sidebar');
|
|
17
|
-
const model = (_a = event.page) === null || _a === void 0 ? void 0 : _a.model;
|
|
18
|
-
const sidebarLabel = model === null || model === void 0 ? void 0 : model.name;
|
|
19
|
-
let pluginFrontmatter = {};
|
|
20
|
-
if (sidebar.autoConfiguration) {
|
|
21
|
-
if (((_b = event.page) === null || _b === void 0 ? void 0 : _b.url) === app.options.getValue('entryFileName')) {
|
|
22
|
-
if (sidebar.categoryLabel) {
|
|
23
|
-
pluginFrontmatter = {
|
|
24
|
-
...pluginFrontmatter,
|
|
25
|
-
sidebar_label: sidebar.categoryLabel,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (hasReadme) {
|
|
30
|
-
if (((_c = event.page) === null || _c === void 0 ? void 0 : _c.url) === entryPage) {
|
|
31
|
-
pluginFrontmatter = {
|
|
32
|
-
...pluginFrontmatter,
|
|
33
|
-
...(sidebar.readmeLabel && { sidebar_label: sidebar.readmeLabel }),
|
|
34
|
-
sidebar_position: 0,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (((_d = event.page) === null || _d === void 0 ? void 0 : _d.url) === `01-${indexPage}`) {
|
|
38
|
-
pluginFrontmatter = {
|
|
39
|
-
...pluginFrontmatter,
|
|
40
|
-
...(sidebar.indexLabel && { sidebar_label: sidebar.indexLabel }),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
if (((_e = event.page) === null || _e === void 0 ? void 0 : _e.url) === entryPage) {
|
|
46
|
-
pluginFrontmatter = {
|
|
47
|
-
...pluginFrontmatter,
|
|
48
|
-
...(sidebar.indexLabel && { sidebar_label: sidebar.indexLabel }),
|
|
49
|
-
sidebar_position: 0,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
// Add sidebar labels to all pages
|
|
54
|
-
if (!(((_f = event.page) === null || _f === void 0 ? void 0 : _f.url) === entryPage) &&
|
|
55
|
-
!(((_g = event.page) === null || _g === void 0 ? void 0 : _g.url) === `01-${indexPage}`)) {
|
|
56
|
-
pluginFrontmatter = {
|
|
57
|
-
...pluginFrontmatter,
|
|
58
|
-
sidebar_label: sidebarLabel,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
event.frontmatter = {
|
|
63
|
-
...pluginFrontmatter,
|
|
64
|
-
...event.frontmatter,
|
|
65
|
-
};
|
|
66
|
-
}
|