docusaurus-plugin-typedoc 1.0.0-next.2 → 1.0.0-next.20
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 +105 -133
- package/dist/index.d.ts +1 -0
- package/dist/models.d.ts +10 -0
- package/dist/options.d.ts +3 -2
- package/dist/options.js +20 -19
- package/dist/plugin.d.ts +4 -1
- package/dist/plugin.js +73 -14
- package/dist/sidebar.d.ts +2 -0
- package/dist/sidebar.js +30 -0
- package/package.json +9 -8
- package/dist/navigation.d.ts +0 -13
- package/dist/navigation.js +0 -36
- package/dist/render.d.ts +0 -5
- package/dist/render.js +0 -77
- package/dist/theme-context.d.ts +0 -11
- package/dist/theme-context.js +0 -43
- package/dist/theme.d.ts +0 -13
- package/dist/theme.js +0 -97
- package/dist/types.d.ts +0 -36
- /package/dist/{types.js → models.js} +0 -0
package/README.md
CHANGED
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
# docusaurus-plugin-typedoc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
 [](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml)
|
|
4
4
|
|
|
5
|
-
[
|
|
6
|
-

|
|
5
|
+
A [Docusaurus](https://v2.docusaurus.io/) plugin to build TypeScript API documentation with [TypeDoc](https://github.com/TypeStrong/typedoc).
|
|
7
6
|
|
|
8
|
-
##
|
|
7
|
+
## Contents
|
|
9
8
|
|
|
10
|
-
|
|
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.
|
|
11
21
|
|
|
12
22
|
## Installation
|
|
13
23
|
|
|
14
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.
|
|
15
25
|
|
|
26
|
+
> [typedoc](https://github.com/TypeStrong/typedoc) and [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown) are peer dependencies.
|
|
27
|
+
|
|
16
28
|
```shell
|
|
17
|
-
npm install typedoc typedoc-plugin-markdown
|
|
29
|
+
npm install docusaurus-plugin-typedoc typedoc typedoc-plugin-markdown@next --save-dev
|
|
18
30
|
```
|
|
19
31
|
|
|
20
32
|
## Usage
|
|
21
33
|
|
|
22
|
-
### Config
|
|
23
|
-
|
|
24
34
|
Add the plugin to `docusaurus.config.js` and specify the required options (see [options](#options)).
|
|
25
35
|
|
|
26
36
|
```js
|
|
@@ -46,130 +56,119 @@ TypeDoc will be bootstraped with the Docusaurus `start` and `build` [cli command
|
|
|
46
56
|
"build": "docusaurus build",
|
|
47
57
|
```
|
|
48
58
|
|
|
49
|
-
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).
|
|
50
60
|
|
|
51
|
-
|
|
61
|
+
Typical directory structure:
|
|
52
62
|
|
|
53
|
-
|
|
54
|
-
├──
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
├──
|
|
62
|
-
├──
|
|
63
|
-
├──tsconfig.json
|
|
64
|
-
```
|
|
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
|
|
65
73
|
|
|
66
74
|
## Options
|
|
67
75
|
|
|
68
76
|
### TypeDoc options
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
Options can be declared:
|
|
71
79
|
|
|
72
|
-
|
|
80
|
+
- Passing arguments via the command line.
|
|
81
|
+
- Using a `typedoc.json` file.
|
|
82
|
+
- Under the `typedocOptions` key in `tsconfig.json`.
|
|
73
83
|
|
|
74
|
-
|
|
75
|
-
entryPoints: ['../src/index.ts'],
|
|
76
|
-
tsconfig: '../tsconfig.json'
|
|
77
|
-
```
|
|
84
|
+
Please see <https://typedoc.org/options/configuration> for general TypeDoc option configuration.
|
|
78
85
|
|
|
79
|
-
|
|
86
|
+
The following TypeDoc / Markdown plugin options can be passed to config:
|
|
80
87
|
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
}
|
|
83
101
|
```
|
|
84
102
|
|
|
85
|
-
|
|
103
|
+
### Plugin options
|
|
86
104
|
|
|
87
|
-
|
|
105
|
+
Options specific to the plugin should also be declared in the same object.
|
|
88
106
|
|
|
89
|
-
|
|
90
|
-
- Under the `typedocOptions` key in `tsconfig.json`.
|
|
107
|
+
#### `--sidebar`
|
|
91
108
|
|
|
92
|
-
|
|
109
|
+
`sidebar.autoConfiguration`
|
|
93
110
|
|
|
94
|
-
|
|
111
|
+
Set to `false` to disable sidebar generation. Defaults to `true`.
|
|
95
112
|
|
|
96
|
-
|
|
113
|
+
`sidebar.filteredIds`
|
|
97
114
|
|
|
98
|
-
|
|
99
|
-
| :---------------------- | :------ | :------------------------------------------------------- |
|
|
100
|
-
| `out` | `"api"` | Output dir relative to docs dir (use `.` for no subdir). |
|
|
101
|
-
| `sidebar.categoryLabel` | `API` | The sidebar parent category label. |
|
|
102
|
-
| `sidebar.fullNames` | `false` | Display full names with module path. |
|
|
103
|
-
| `sidebar.position` | `auto` | The position of the sidebar in the tree. |
|
|
115
|
+
Ids of pages to be filtered from the sidebar. This would typically be used to filter README or index pages from the sidebar.
|
|
104
116
|
|
|
105
|
-
|
|
117
|
+
`sidebar.pretty`
|
|
106
118
|
|
|
107
|
-
|
|
108
|
-
module.exports = {
|
|
109
|
-
plugins: [
|
|
110
|
-
[
|
|
111
|
-
'docusaurus-plugin-typedoc',
|
|
112
|
-
{
|
|
113
|
-
// TypeDoc options
|
|
114
|
-
entryPoints: ['../src/index.ts'],
|
|
115
|
-
tsconfig: '../tsconfig.json',
|
|
116
|
-
plugin: ['typedoc-plugin-xyz'],
|
|
117
|
-
|
|
118
|
-
// Plugin options
|
|
119
|
-
out: 'api-xyz',
|
|
120
|
-
sidebar: {
|
|
121
|
-
categoryLabel: 'API XYZ',
|
|
122
|
-
position: 0,
|
|
123
|
-
fullNames: true,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
],
|
|
128
|
-
};
|
|
129
|
-
```
|
|
119
|
+
Pretty format the sidebar JSON.
|
|
130
120
|
|
|
131
|
-
##
|
|
121
|
+
## Sidebar
|
|
132
122
|
|
|
133
|
-
|
|
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.
|
|
134
124
|
|
|
135
|
-
|
|
125
|
+
A docusaurus sidebar file `typedoc-sidebar.cjs` is published to the relevant output directory along with the generated markdown documentation.
|
|
136
126
|
|
|
137
|
-
`sidebars.js` can be configured in following ways:
|
|
127
|
+
This file should be referenced in `sidebars.js` using a sidebar slice and can be configured in following ways:
|
|
138
128
|
|
|
139
|
-
1.
|
|
129
|
+
1. Display sidebar on the root:
|
|
140
130
|
|
|
141
131
|
```js
|
|
142
132
|
module.exports = {
|
|
143
|
-
|
|
144
|
-
{
|
|
145
|
-
type: 'autogenerated',
|
|
146
|
-
dirName: '.', // '.' means the docs folder
|
|
147
|
-
},
|
|
148
|
-
],
|
|
133
|
+
typedocSidebar: require('./docs/api/typedoc-sidebar.cjs'),
|
|
149
134
|
};
|
|
150
135
|
```
|
|
151
136
|
|
|
152
|
-
2.
|
|
137
|
+
2. Display the sidebar inside a category:
|
|
153
138
|
|
|
154
|
-
|
|
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`]().
|
|
155
150
|
|
|
156
151
|
```js
|
|
157
152
|
module.exports = {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
153
|
+
typedocSidebar: [
|
|
154
|
+
{
|
|
155
|
+
type: 'category',
|
|
156
|
+
label: 'Typedoc Docs',
|
|
157
|
+
link: {
|
|
158
|
+
type: 'doc',
|
|
159
|
+
id: 'api/index',
|
|
164
160
|
},
|
|
165
|
-
|
|
166
|
-
|
|
161
|
+
items: require('./docs/api/typedoc-sidebar.js'),
|
|
162
|
+
},
|
|
163
|
+
],
|
|
167
164
|
};
|
|
168
165
|
```
|
|
169
166
|
|
|
170
|
-
Please see https://docusaurus.io/docs/sidebar for sidebar documentation.
|
|
167
|
+
Please see <https://docusaurus.io/docs/sidebar> for sidebar documentation.
|
|
171
168
|
|
|
172
|
-
|
|
169
|
+
## Other configuration
|
|
170
|
+
|
|
171
|
+
### Navbar
|
|
173
172
|
|
|
174
173
|
A navbar item can be configured in `themeConfig` options in `docusaurus.config.js`:
|
|
175
174
|
|
|
@@ -188,28 +187,7 @@ A navbar item can be configured in `themeConfig` options in `docusaurus.config.j
|
|
|
188
187
|
},
|
|
189
188
|
```
|
|
190
189
|
|
|
191
|
-
Please see https://docusaurus.io/docs/api/themes/configuration#navbar-items for navbar documentation.
|
|
192
|
-
|
|
193
|
-
### Frontmatter
|
|
194
|
-
|
|
195
|
-
By default the plugin will configure minimal required [Frontmatter](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs#markdown-front-matter) configuration.
|
|
196
|
-
Additionally required global Frontmatter options can be passed in using the `frontmatterGlobals` options object
|
|
197
|
-
|
|
198
|
-
`docusaurus.config.js`:
|
|
199
|
-
|
|
200
|
-
```js
|
|
201
|
-
plugins: [
|
|
202
|
-
[
|
|
203
|
-
'docusaurus-plugin-typedoc',
|
|
204
|
-
{
|
|
205
|
-
// .... other plugin option
|
|
206
|
-
frontmatterGlobals: {
|
|
207
|
-
pagination_prev: null,
|
|
208
|
-
pagination_next: null
|
|
209
|
-
}
|
|
210
|
-
]
|
|
211
|
-
]
|
|
212
|
-
```
|
|
190
|
+
Please see <https://docusaurus.io/docs/api/themes/configuration#navbar-items> for navbar documentation.
|
|
213
191
|
|
|
214
192
|
### Multi instance
|
|
215
193
|
|
|
@@ -242,9 +220,20 @@ module.exports = {
|
|
|
242
220
|
};
|
|
243
221
|
```
|
|
244
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
|
+
|
|
245
234
|
### Watch mode
|
|
246
235
|
|
|
247
|
-
Watching files is supported by passing in the `watch: true` option see
|
|
236
|
+
Watching files is supported by passing in the `watch: true` option see <https://typedoc.org/guides/options/#watch>.
|
|
248
237
|
|
|
249
238
|
Targetting the option in development mode only can be achieved using Node.js Environment Variables:
|
|
250
239
|
|
|
@@ -272,26 +261,9 @@ module.exports = {
|
|
|
272
261
|
};
|
|
273
262
|
```
|
|
274
263
|
|
|
275
|
-
###
|
|
276
|
-
|
|
277
|
-
`docusaurus.config.js`
|
|
264
|
+
### Frontmatter
|
|
278
265
|
|
|
279
|
-
|
|
280
|
-
module.exports = {
|
|
281
|
-
plugins: [
|
|
282
|
-
[
|
|
283
|
-
'docusaurus-plugin-typedoc',
|
|
284
|
-
{
|
|
285
|
-
entryPoints: ['../packages/package-a', '../packages/package-b'],
|
|
286
|
-
entryPointStrategy: 'packages',
|
|
287
|
-
sidebar: {
|
|
288
|
-
fullNames: true,
|
|
289
|
-
},
|
|
290
|
-
},
|
|
291
|
-
],
|
|
292
|
-
],
|
|
293
|
-
};
|
|
294
|
-
```
|
|
266
|
+
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.
|
|
295
267
|
|
|
296
268
|
## License
|
|
297
269
|
|
package/dist/index.d.ts
CHANGED
package/dist/models.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PluginOptions as TypedocPluginMarkdownOptions } from 'typedoc-plugin-markdown';
|
|
2
|
+
export interface PluginOptions extends TypedocPluginMarkdownOptions {
|
|
3
|
+
id: string;
|
|
4
|
+
sidebar: Partial<SidebarOptions>;
|
|
5
|
+
}
|
|
6
|
+
export interface SidebarOptions {
|
|
7
|
+
autoConfiguration: boolean;
|
|
8
|
+
pretty: boolean;
|
|
9
|
+
filteredIds: string[];
|
|
10
|
+
}
|
package/dist/options.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
1
|
+
import { Application } from 'typedoc';
|
|
2
|
+
export declare function getPluginOptions(opts: Record<string, any>): Record<string, any>;
|
|
3
|
+
export declare function setOptions(app: Application, options: any): void;
|
package/dist/options.js
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPluginOptions = void 0;
|
|
3
|
+
exports.setOptions = exports.getPluginOptions = void 0;
|
|
4
4
|
const DEFAULT_PLUGIN_OPTIONS = {
|
|
5
5
|
id: 'default',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
out: './docs/api',
|
|
7
|
+
hideInPageTOC: true,
|
|
8
|
+
hideBreadcrumbs: true,
|
|
9
|
+
hidePageHeader: true,
|
|
10
|
+
entryFileName: 'index.md',
|
|
9
11
|
sidebar: {
|
|
10
|
-
fullNames: false,
|
|
11
|
-
categoryLabel: 'API',
|
|
12
|
-
collapsed: true,
|
|
13
|
-
indexLabel: 'Overview',
|
|
14
|
-
position: null,
|
|
15
12
|
autoConfiguration: true,
|
|
13
|
+
pretty: false,
|
|
14
|
+
filteredIds: [],
|
|
16
15
|
},
|
|
17
|
-
|
|
18
|
-
hideBreadcrumbs: true,
|
|
19
|
-
hidePageTitle: false,
|
|
20
|
-
entryDocument: 'index.md',
|
|
21
|
-
plugin: ['none'],
|
|
22
|
-
watch: false,
|
|
23
|
-
theme: 'docusaurus',
|
|
24
|
-
enableFrontmatter: true,
|
|
16
|
+
plugin: ['typedoc-plugin-markdown'],
|
|
25
17
|
};
|
|
26
|
-
|
|
18
|
+
function getPluginOptions(opts) {
|
|
27
19
|
const options = {
|
|
28
20
|
...DEFAULT_PLUGIN_OPTIONS,
|
|
29
21
|
...opts,
|
|
@@ -31,7 +23,16 @@ const getPluginOptions = (opts) => {
|
|
|
31
23
|
...DEFAULT_PLUGIN_OPTIONS.sidebar,
|
|
32
24
|
...opts.sidebar,
|
|
33
25
|
},
|
|
26
|
+
plugin: [
|
|
27
|
+
...new Set([...DEFAULT_PLUGIN_OPTIONS.plugin, ...(opts.plugin || [])]),
|
|
28
|
+
],
|
|
34
29
|
};
|
|
35
30
|
return options;
|
|
36
|
-
}
|
|
31
|
+
}
|
|
37
32
|
exports.getPluginOptions = getPluginOptions;
|
|
33
|
+
function setOptions(app, options) {
|
|
34
|
+
for (const [key, val] of Object.entries(options)) {
|
|
35
|
+
app.options.setValue(key, val);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.setOptions = setOptions;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { PluginOptions } from '
|
|
1
|
+
import { PluginOptions } from '.';
|
|
2
2
|
export default function pluginDocusaurus(context: any, opts: Partial<PluginOptions>): {
|
|
3
3
|
name: string;
|
|
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,12 +23,13 @@ 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
|
-
const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
|
|
29
30
|
const options_1 = require("./options");
|
|
30
|
-
const
|
|
31
|
-
|
|
31
|
+
const sidebar_1 = require("./sidebar");
|
|
32
|
+
// store list of plugin ids when running multiple instances
|
|
32
33
|
const apps = [];
|
|
33
34
|
function pluginDocusaurus(context, opts) {
|
|
34
35
|
return {
|
|
@@ -36,7 +37,7 @@ function pluginDocusaurus(context, opts) {
|
|
|
36
37
|
async loadContent() {
|
|
37
38
|
if (opts.id && !apps.includes(opts.id)) {
|
|
38
39
|
apps.push(opts.id);
|
|
39
|
-
generateTypedoc(context, opts);
|
|
40
|
+
await generateTypedoc(context, opts);
|
|
40
41
|
}
|
|
41
42
|
},
|
|
42
43
|
extendCli(cli) {
|
|
@@ -46,6 +47,7 @@ function pluginDocusaurus(context, opts) {
|
|
|
46
47
|
.action(async () => {
|
|
47
48
|
var _a;
|
|
48
49
|
(_a = context.siteConfig) === null || _a === void 0 ? void 0 : _a.plugins.forEach((pluginConfig) => {
|
|
50
|
+
// Check PluginConfig is typed to [string, PluginOptions]
|
|
49
51
|
if (pluginConfig && typeof pluginConfig[1] === 'object') {
|
|
50
52
|
generateTypedoc(context, pluginConfig[1]);
|
|
51
53
|
}
|
|
@@ -55,22 +57,50 @@ function pluginDocusaurus(context, opts) {
|
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
exports.default = pluginDocusaurus;
|
|
60
|
+
/**
|
|
61
|
+
* Initiates a new typedoc Application bootstraped with plugin options
|
|
62
|
+
*/
|
|
58
63
|
async function generateTypedoc(context, opts) {
|
|
64
|
+
var _a, _b;
|
|
59
65
|
const { siteDir } = context;
|
|
60
66
|
const options = (0, options_1.getPluginOptions)(opts);
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
67
|
+
const { id, sidebar, ...optionsPassedToTypeDoc } = options;
|
|
68
|
+
const app = await typedoc_1.Application.bootstrapWithPlugins(optionsPassedToTypeDoc);
|
|
69
|
+
const outputDir = app.options.getValue('out');
|
|
70
|
+
if (options.cleanOutputDir) {
|
|
71
|
+
removeDir(outputDir);
|
|
64
72
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
if (((_b = (_a = context.siteConfig) === null || _a === void 0 ? void 0 : _a.markdown) === null || _b === void 0 ? void 0 : _b.format) !== 'mdx') {
|
|
74
|
+
app.renderer.on(typedoc_1.PageEvent.END, (event) => {
|
|
75
|
+
var _a;
|
|
76
|
+
event.contents = (_a = event.contents) === null || _a === void 0 ? void 0 : _a.replace(/\\</g, '<');
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (sidebar === null || sidebar === void 0 ? void 0 : sidebar.autoConfiguration) {
|
|
80
|
+
app.renderer.postRenderAsyncJobs.push(async (output) => {
|
|
81
|
+
const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
|
|
82
|
+
const baseDir = path
|
|
83
|
+
.relative(siteDir, outputDir)
|
|
84
|
+
.split(path.sep)
|
|
85
|
+
.slice(1)
|
|
86
|
+
.join(path.sep);
|
|
87
|
+
const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, baseDir, sidebar.filteredIds);
|
|
88
|
+
fs.writeFileSync(sidebarPath, `// @ts-check
|
|
89
|
+
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
|
90
|
+
const typedocSidebar = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
|
|
91
|
+
module.exports = typedocSidebar.items;`);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
const project = await app.convert();
|
|
95
|
+
// if project is undefined typedoc has a problem - error logging will be supplied by typedoc.
|
|
70
96
|
if (!project) {
|
|
71
|
-
|
|
97
|
+
if (app.options.getValue('skipErrorChecking')) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
console.error('[docusaurus-plugin-typedoc] TypeDoc exited with an error. Use the "skipErrorChecking" option to disable TypeDoc error checking.');
|
|
101
|
+
process.exit();
|
|
72
102
|
}
|
|
73
|
-
if (options.watch) {
|
|
103
|
+
if (app.options.getValue('watch')) {
|
|
74
104
|
app.convertAndWatch(async (project) => {
|
|
75
105
|
await app.generateDocs(project, outputDir);
|
|
76
106
|
});
|
|
@@ -79,3 +109,32 @@ async function generateTypedoc(context, opts) {
|
|
|
79
109
|
await app.generateDocs(project, outputDir);
|
|
80
110
|
}
|
|
81
111
|
}
|
|
112
|
+
function writeFileSync(fileName, data) {
|
|
113
|
+
fs.mkdirSync(path.dirname(normalizePath(fileName)), { recursive: true });
|
|
114
|
+
fs.writeFileSync(normalizePath(fileName), data);
|
|
115
|
+
}
|
|
116
|
+
exports.writeFileSync = writeFileSync;
|
|
117
|
+
function normalizePath(path) {
|
|
118
|
+
return path.replace(/\\/g, '/');
|
|
119
|
+
}
|
|
120
|
+
exports.normalizePath = normalizePath;
|
|
121
|
+
function removeDir(path) {
|
|
122
|
+
if (fs.existsSync(path)) {
|
|
123
|
+
const files = fs.readdirSync(path);
|
|
124
|
+
if (files.length > 0) {
|
|
125
|
+
files.forEach(function (filename) {
|
|
126
|
+
if (fs.statSync(path + '/' + filename).isDirectory()) {
|
|
127
|
+
removeDir(path + '/' + filename);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
fs.unlinkSync(path + '/' + filename);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
fs.rmdirSync(path);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
fs.rmdirSync(path);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.removeDir = removeDir;
|
package/dist/sidebar.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSidebar = void 0;
|
|
4
|
+
function getSidebar(navigation, basePath, filteredIds = []) {
|
|
5
|
+
return navigation
|
|
6
|
+
.map((navigationItem) => getNavigationItem(navigationItem, basePath, filteredIds))
|
|
7
|
+
.filter((navItem) => Boolean(navItem));
|
|
8
|
+
}
|
|
9
|
+
exports.getSidebar = getSidebar;
|
|
10
|
+
function getNavigationItem(navigationItem, basePath, filteredIds) {
|
|
11
|
+
var _a;
|
|
12
|
+
const id = navigationItem.url
|
|
13
|
+
? `${basePath}/${navigationItem.url.replace(/\d+\-/g, '')}`.replace(/(.*).md/, '$1')
|
|
14
|
+
: null;
|
|
15
|
+
if ((_a = navigationItem.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
16
|
+
return {
|
|
17
|
+
type: 'category',
|
|
18
|
+
label: navigationItem.title,
|
|
19
|
+
items: getSidebar(navigationItem.children, basePath, filteredIds),
|
|
20
|
+
...(id && { link: { type: 'doc', id } }),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return id && !filteredIds.includes(id)
|
|
24
|
+
? {
|
|
25
|
+
type: 'doc',
|
|
26
|
+
id,
|
|
27
|
+
label: navigationItem.title,
|
|
28
|
+
}
|
|
29
|
+
: null;
|
|
30
|
+
}
|
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
|
|
3
|
+
"version": "1.0.0-next.20",
|
|
4
|
+
"description": "A Docusaurus plugin to build API documentation with TypeDoc.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist/"
|
|
@@ -16,15 +16,13 @@
|
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"typedoc": ">=0.
|
|
20
|
-
"typedoc-plugin-markdown": ">=4.0.0-next.2"
|
|
19
|
+
"typedoc-plugin-markdown": ">=4.0.0-next.24"
|
|
21
20
|
},
|
|
22
21
|
"scripts": {
|
|
23
22
|
"lint": "eslint ./src --ext .ts",
|
|
24
|
-
"prepublishOnly": "npm run lint && npm run build
|
|
23
|
+
"prepublishOnly": "npm run lint && npm run build",
|
|
25
24
|
"build": "rm -rf ./dist && tsc",
|
|
26
|
-
"
|
|
27
|
-
"test": "jest --colors"
|
|
25
|
+
"task:docs": "node ./tasks/docs.mjs"
|
|
28
26
|
},
|
|
29
27
|
"author": "Thomas Grey",
|
|
30
28
|
"license": "MIT",
|
|
@@ -35,5 +33,8 @@
|
|
|
35
33
|
"markdown",
|
|
36
34
|
"typescript",
|
|
37
35
|
"api"
|
|
38
|
-
]
|
|
36
|
+
],
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@docusaurus/types": "^3.0.0"
|
|
39
|
+
}
|
|
39
40
|
}
|
package/dist/navigation.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ReflectionKind } from 'typedoc';
|
|
2
|
-
export declare const CATEGORY_POSITION: {
|
|
3
|
-
2: number;
|
|
4
|
-
4: number;
|
|
5
|
-
8: number;
|
|
6
|
-
128: number;
|
|
7
|
-
256: number;
|
|
8
|
-
4194304: number;
|
|
9
|
-
32: number;
|
|
10
|
-
64: number;
|
|
11
|
-
2097152: number;
|
|
12
|
-
};
|
|
13
|
-
export declare function getKindPlural(kind: ReflectionKind): string;
|
package/dist/navigation.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getKindPlural = exports.CATEGORY_POSITION = void 0;
|
|
4
|
-
const typedoc_1 = require("typedoc");
|
|
5
|
-
const PLURALS = {
|
|
6
|
-
[typedoc_1.ReflectionKind.Class]: 'Classes',
|
|
7
|
-
[typedoc_1.ReflectionKind.Property]: 'Properties',
|
|
8
|
-
[typedoc_1.ReflectionKind.Enum]: 'Enumerations',
|
|
9
|
-
[typedoc_1.ReflectionKind.EnumMember]: 'Enumeration members',
|
|
10
|
-
[typedoc_1.ReflectionKind.TypeAlias]: 'Type aliases',
|
|
11
|
-
};
|
|
12
|
-
exports.CATEGORY_POSITION = {
|
|
13
|
-
[typedoc_1.ReflectionKind.Module]: 1,
|
|
14
|
-
[typedoc_1.ReflectionKind.Namespace]: 1,
|
|
15
|
-
[typedoc_1.ReflectionKind.Enum]: 2,
|
|
16
|
-
[typedoc_1.ReflectionKind.Class]: 3,
|
|
17
|
-
[typedoc_1.ReflectionKind.Interface]: 4,
|
|
18
|
-
[typedoc_1.ReflectionKind.TypeAlias]: 5,
|
|
19
|
-
[typedoc_1.ReflectionKind.Variable]: 6,
|
|
20
|
-
[typedoc_1.ReflectionKind.Function]: 7,
|
|
21
|
-
[typedoc_1.ReflectionKind.ObjectLiteral]: 8,
|
|
22
|
-
};
|
|
23
|
-
function getKindPlural(kind) {
|
|
24
|
-
if (kind in PLURALS) {
|
|
25
|
-
return PLURALS[kind];
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
return getKindString(kind) + 's';
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.getKindPlural = getKindPlural;
|
|
32
|
-
function getKindString(kind) {
|
|
33
|
-
let str = typedoc_1.ReflectionKind[kind];
|
|
34
|
-
str = str.replace(/(.)([A-Z])/g, (_m, a, b) => a + ' ' + b.toLowerCase());
|
|
35
|
-
return str;
|
|
36
|
-
}
|
package/dist/render.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Application, ProjectReflection } from 'typedoc';
|
|
2
|
-
import { PluginOptions } from './types';
|
|
3
|
-
export declare const bootstrap: (app: Application, options: PluginOptions) => void;
|
|
4
|
-
export declare function render(project: ProjectReflection, outputDirectory: string): Promise<void>;
|
|
5
|
-
export declare function removeDir(path: string): void;
|
package/dist/render.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.removeDir = exports.render = exports.bootstrap = void 0;
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
const typedoc_1 = require("typedoc");
|
|
29
|
-
const bootstrap = (app, options) => {
|
|
30
|
-
addTypedocReaders(app);
|
|
31
|
-
addTypedocDeclarations(app);
|
|
32
|
-
app.renderer.render = render;
|
|
33
|
-
app.bootstrap(options);
|
|
34
|
-
};
|
|
35
|
-
exports.bootstrap = bootstrap;
|
|
36
|
-
async function render(project, outputDirectory) {
|
|
37
|
-
var _a;
|
|
38
|
-
if (!this.prepareTheme()) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const output = new typedoc_1.RendererEvent(typedoc_1.RendererEvent.BEGIN, outputDirectory, project);
|
|
42
|
-
output.urls = this.theme.getUrls(project);
|
|
43
|
-
this.trigger(output);
|
|
44
|
-
if (!output.isDefaultPrevented) {
|
|
45
|
-
(_a = output === null || output === void 0 ? void 0 : output.urls) === null || _a === void 0 ? void 0 : _a.forEach((mapping) => {
|
|
46
|
-
this.renderDocument(output.createPageEvent(mapping));
|
|
47
|
-
});
|
|
48
|
-
this.trigger(typedoc_1.RendererEvent.END, output);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.render = render;
|
|
52
|
-
const addTypedocReaders = (app) => {
|
|
53
|
-
app.options.addReader(new typedoc_1.TypeDocReader());
|
|
54
|
-
app.options.addReader(new typedoc_1.TSConfigReader());
|
|
55
|
-
};
|
|
56
|
-
const addTypedocDeclarations = (app) => {
|
|
57
|
-
app.options.addDeclaration({
|
|
58
|
-
name: 'id',
|
|
59
|
-
});
|
|
60
|
-
app.options.addDeclaration({
|
|
61
|
-
name: 'docsRoot',
|
|
62
|
-
});
|
|
63
|
-
app.options.addDeclaration({
|
|
64
|
-
name: 'siteDir',
|
|
65
|
-
});
|
|
66
|
-
app.options.addDeclaration({
|
|
67
|
-
name: 'globalsTitle',
|
|
68
|
-
});
|
|
69
|
-
app.options.addDeclaration({
|
|
70
|
-
name: 'sidebar',
|
|
71
|
-
type: typedoc_1.ParameterType.Mixed,
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
|
-
function removeDir(path) {
|
|
75
|
-
fs.rmSync(path, { recursive: true, force: true });
|
|
76
|
-
}
|
|
77
|
-
exports.removeDir = removeDir;
|
package/dist/theme-context.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DeclarationReflection, PageEvent, Reflection } from 'typedoc';
|
|
2
|
-
import { MarkdownThemeRenderContext } from 'typedoc-plugin-markdown';
|
|
3
|
-
export declare class DocusaurusThemeRenderContext extends MarkdownThemeRenderContext {
|
|
4
|
-
baseFrontmatterVars: (page: PageEvent<Reflection>) => {
|
|
5
|
-
sidebar_position?: number | undefined;
|
|
6
|
-
sidebar_label?: string | undefined;
|
|
7
|
-
title: string;
|
|
8
|
-
};
|
|
9
|
-
getSidebarLabel(page: PageEvent<DeclarationReflection>): string | null | undefined;
|
|
10
|
-
getSidebarPosition(page: PageEvent<DeclarationReflection>): "0.5" | "0" | null;
|
|
11
|
-
}
|
package/dist/theme-context.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DocusaurusThemeRenderContext = void 0;
|
|
4
|
-
const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
|
|
5
|
-
class DocusaurusThemeRenderContext extends typedoc_plugin_markdown_1.MarkdownThemeRenderContext {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.baseFrontmatterVars = (page) => {
|
|
9
|
-
const sidebarPosition = parseFloat(this.getSidebarPosition(page));
|
|
10
|
-
const sidebarLabel = this.getSidebarLabel(page);
|
|
11
|
-
return {
|
|
12
|
-
...this.getBaseFrontmatterVars(page),
|
|
13
|
-
...(this.options.getValue('sidebar').autoConfiguration
|
|
14
|
-
? {
|
|
15
|
-
...(sidebarLabel && { sidebar_label: sidebarLabel }),
|
|
16
|
-
...(sidebarPosition && {
|
|
17
|
-
sidebar_position: sidebarPosition,
|
|
18
|
-
}),
|
|
19
|
-
}
|
|
20
|
-
: {}),
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
getSidebarLabel(page) {
|
|
25
|
-
if (page.url === this.options.getValue('entryDocument')) {
|
|
26
|
-
return this.options.getValue('sidebar').indexLabel;
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
getSidebarPosition(page) {
|
|
31
|
-
if (page.url === this.options.getValue('entryDocument')) {
|
|
32
|
-
return page.url === page.project.url ? '0.5' : '0';
|
|
33
|
-
}
|
|
34
|
-
if (page.url === this.globalsFile) {
|
|
35
|
-
return '0.5';
|
|
36
|
-
}
|
|
37
|
-
if (page.model.getFullName().split('.').length === 1) {
|
|
38
|
-
return '0';
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.DocusaurusThemeRenderContext = DocusaurusThemeRenderContext;
|
package/dist/theme.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DeclarationReflection, PageEvent, Renderer, RendererEvent } from 'typedoc';
|
|
2
|
-
import { MarkdownTheme } from 'typedoc-plugin-markdown';
|
|
3
|
-
import { SidebarOptions } from './types';
|
|
4
|
-
export declare class DocusaurusTheme extends MarkdownTheme {
|
|
5
|
-
sidebar: SidebarOptions;
|
|
6
|
-
private _contextCache?;
|
|
7
|
-
constructor(renderer: Renderer);
|
|
8
|
-
getRenderContext(): any;
|
|
9
|
-
onPageEnd(page: PageEvent<DeclarationReflection>): void;
|
|
10
|
-
onRendererEnd(renderer: RendererEvent): void;
|
|
11
|
-
loopAndWriteCategories(path: string): void;
|
|
12
|
-
writeCategoryYaml: (categoryPath: string, label: string, position: number | null, collapsed: boolean) => void;
|
|
13
|
-
}
|
package/dist/theme.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.DocusaurusTheme = void 0;
|
|
33
|
-
const fs = __importStar(require("fs"));
|
|
34
|
-
const typedoc_1 = require("typedoc");
|
|
35
|
-
const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
|
|
36
|
-
const navigation_1 = require("./navigation");
|
|
37
|
-
const theme_context_1 = require("./theme-context");
|
|
38
|
-
class DocusaurusTheme extends typedoc_plugin_markdown_1.MarkdownTheme {
|
|
39
|
-
constructor(renderer) {
|
|
40
|
-
super(renderer);
|
|
41
|
-
this.writeCategoryYaml = (categoryPath, label, position, collapsed) => {
|
|
42
|
-
const yaml = [`label: "${label}"`];
|
|
43
|
-
if (position !== null) {
|
|
44
|
-
yaml.push(`position: ${position}`);
|
|
45
|
-
}
|
|
46
|
-
if (!collapsed) {
|
|
47
|
-
yaml.push(`collapsed: false`);
|
|
48
|
-
}
|
|
49
|
-
if (fs.existsSync(categoryPath)) {
|
|
50
|
-
fs.writeFileSync(categoryPath + '/_category_.yml', yaml.join('\n'));
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
this.listenTo(this.application.renderer, {
|
|
54
|
-
[typedoc_1.PageEvent.END]: this.onPageEnd,
|
|
55
|
-
[typedoc_1.RendererEvent.END]: this.onRendererEnd,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
getRenderContext() {
|
|
59
|
-
this._contextCache || (this._contextCache = new theme_context_1.DocusaurusThemeRenderContext(this, this.application.options));
|
|
60
|
-
return this._contextCache;
|
|
61
|
-
}
|
|
62
|
-
onPageEnd(page) {
|
|
63
|
-
if (page.contents) {
|
|
64
|
-
page.contents = page.contents.replace(/\\</g, '<');
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
onRendererEnd(renderer) {
|
|
68
|
-
if (this.sidebar.autoConfiguration) {
|
|
69
|
-
this.writeCategoryYaml(renderer.outputDirectory, this.sidebar.categoryLabel, this.sidebar.position, this.sidebar.collapsed);
|
|
70
|
-
this.loopAndWriteCategories(renderer.outputDirectory);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
loopAndWriteCategories(path) {
|
|
74
|
-
const directory = fs.readdirSync(path);
|
|
75
|
-
directory.forEach((segment) => {
|
|
76
|
-
const fullPath = `${path}/${segment}`;
|
|
77
|
-
const isDirectory = fs.lstatSync(fullPath).isDirectory();
|
|
78
|
-
if (isDirectory) {
|
|
79
|
-
const mapping = Object.entries(this.mappings)
|
|
80
|
-
.filter((entry) => {
|
|
81
|
-
return entry[1].directory === segment;
|
|
82
|
-
})
|
|
83
|
-
.map((entry) => entry[1])[0];
|
|
84
|
-
const subdirectory = fs.readdirSync(fullPath);
|
|
85
|
-
const containsDir = subdirectory.some((item) => fs.lstatSync(`${fullPath}/${item}`).isDirectory());
|
|
86
|
-
if (mapping && !containsDir) {
|
|
87
|
-
this.writeCategoryYaml(fullPath, (0, navigation_1.getKindPlural)(mapping.kind), navigation_1.CATEGORY_POSITION[mapping.kind], true);
|
|
88
|
-
}
|
|
89
|
-
this.loopAndWriteCategories(fullPath);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
__decorate([
|
|
95
|
-
(0, typedoc_1.BindOption)('sidebar')
|
|
96
|
-
], DocusaurusTheme.prototype, "sidebar", void 0);
|
|
97
|
-
exports.DocusaurusTheme = DocusaurusTheme;
|
package/dist/types.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export interface PluginOptions {
|
|
2
|
-
id: string;
|
|
3
|
-
docsRoot: string;
|
|
4
|
-
out: string;
|
|
5
|
-
sidebar: SidebarOptions;
|
|
6
|
-
readmeTitle?: string;
|
|
7
|
-
globalsTitle?: string;
|
|
8
|
-
plugin: string[];
|
|
9
|
-
readme?: string;
|
|
10
|
-
disableOutputCheck?: boolean;
|
|
11
|
-
cleanOutputDir?: boolean;
|
|
12
|
-
entryPoints?: string[];
|
|
13
|
-
watch: boolean;
|
|
14
|
-
hideInPageTOC: boolean;
|
|
15
|
-
hideBreadcrumbs: boolean;
|
|
16
|
-
hidePageTitle: boolean;
|
|
17
|
-
entryDocument: string;
|
|
18
|
-
includeExtension?: boolean;
|
|
19
|
-
theme?: string;
|
|
20
|
-
enableFrontmatter: boolean;
|
|
21
|
-
}
|
|
22
|
-
export type FrontMatter = Record<string, string | boolean | number | null> | undefined;
|
|
23
|
-
export interface SidebarOptions {
|
|
24
|
-
fullNames?: boolean;
|
|
25
|
-
categoryLabel: string;
|
|
26
|
-
collapsed: boolean;
|
|
27
|
-
indexLabel?: string;
|
|
28
|
-
position: number | null;
|
|
29
|
-
autoConfiguration: boolean;
|
|
30
|
-
}
|
|
31
|
-
export interface SidebarCategory {
|
|
32
|
-
type: string;
|
|
33
|
-
label: string;
|
|
34
|
-
items: SidebarItem[];
|
|
35
|
-
}
|
|
36
|
-
export type SidebarItem = SidebarCategory | string;
|
|
File without changes
|