docusaurus-plugin-typedoc 1.0.0-next.1 → 1.0.0-next.10
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 +67 -68
- package/dist/index.d.ts +6 -1
- package/dist/index.js +78 -5
- package/dist/models.d.ts +23 -0
- package/dist/options.d.ts +4 -2
- package/dist/options.js +38 -16
- package/dist/renderer.d.ts +2 -0
- package/dist/renderer.js +72 -0
- package/package.json +5 -3
- package/dist/navigation.d.ts +0 -13
- package/dist/navigation.js +0 -36
- package/dist/plugin.d.ts +0 -6
- package/dist/plugin.js +0 -81
- 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 -37
- /package/dist/{types.js → models.js} +0 -0
package/README.md
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
# docusaurus-plugin-typedoc
|
|
2
2
|
|
|
3
|
-
A [Docusaurus
|
|
3
|
+
A [Docusaurus](https://v2.docusaurus.io/) plugin to build TypeScript API documentation with [TypeDoc](https://github.com/TypeStrong/typedoc).
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/docusaurus-plugin-typedoc)
|
|
6
6
|

|
|
7
7
|
|
|
8
|
-
## What it
|
|
8
|
+
## What does it do?
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
- Presets relevant options of [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/typedoc-plugin-markdown#readme).
|
|
11
|
+
- Runs TypeDoc from the Docusaurus CLI.
|
|
12
|
+
- Adds some basic frontmatter to pages and exposes the ability to configure frontmatter further.
|
|
11
13
|
|
|
12
14
|
## Installation
|
|
13
15
|
|
|
14
16
|
> 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
17
|
|
|
18
|
+
> [typedoc](https://github.com/TypeStrong/typedoc), [typedoc-plugin-markdown](https://github.com/tgreyuk/typedoc-plugin-markdown) are peer dependencies.
|
|
19
|
+
|
|
16
20
|
```shell
|
|
17
|
-
npm install typedoc typedoc-plugin-markdown
|
|
21
|
+
npm install docusaurus-plugin-typedoc typedoc typedoc-plugin-markdown@next --save-dev
|
|
18
22
|
```
|
|
19
23
|
|
|
20
24
|
## Usage
|
|
@@ -65,42 +69,64 @@ Once built the docs will be available at `/docs/api` (or equivalent out director
|
|
|
65
69
|
|
|
66
70
|
## Options
|
|
67
71
|
|
|
72
|
+
Options can be declared:
|
|
73
|
+
|
|
74
|
+
- Passing arguments via the command line.
|
|
75
|
+
- Using a `typedoc.json` file.
|
|
76
|
+
- Under the `typedocOptions` key in `tsconfig.json`.
|
|
77
|
+
|
|
78
|
+
Please see https://typedoc.org/options/configuration for general TypeDoc option configuration.
|
|
79
|
+
|
|
68
80
|
### TypeDoc options
|
|
69
81
|
|
|
70
|
-
|
|
82
|
+
The following TypeDoc / Markdown plugin options can be passed to config:
|
|
71
83
|
|
|
72
|
-
|
|
84
|
+
- [typedoc](https://typedoc.org/options) options (HTML specific output options that will be ignored).
|
|
85
|
+
- [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).
|
|
73
86
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
87
|
+
The following typedoc-plugin-markdown options are preset with the plugin.
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"out": "api",
|
|
92
|
+
"hideInPageTOC": true,
|
|
93
|
+
"hideBreadcrumbs": true,
|
|
94
|
+
"hidePageHeader": true,
|
|
95
|
+
"entryFileName": "index.md",
|
|
96
|
+
"globalsPageStrategy": "skip",
|
|
97
|
+
"includeFileNumberPrefixes": true
|
|
98
|
+
}
|
|
77
99
|
```
|
|
78
100
|
|
|
79
|
-
|
|
101
|
+
### Plugin options
|
|
80
102
|
|
|
81
|
-
|
|
82
|
-
plugin: ['typedoc-plugin-xyz'];
|
|
83
|
-
```
|
|
103
|
+
Options specific to the plugin should also be declared in the same object.
|
|
84
104
|
|
|
85
|
-
####
|
|
105
|
+
#### `--sidebar`
|
|
86
106
|
|
|
87
|
-
|
|
107
|
+
`sidebar.autoConfiguration`
|
|
88
108
|
|
|
89
|
-
|
|
90
|
-
- Under the `typedocOptions` key in `tsconfig.json`.
|
|
109
|
+
Set to `false` to disable sidebar generation. Defaults to `true`.
|
|
91
110
|
|
|
92
|
-
|
|
111
|
+
`sidebar.categoryLabel`
|
|
93
112
|
|
|
94
|
-
|
|
113
|
+
The sidebar main parent category label. Defaults to `API`.
|
|
95
114
|
|
|
96
|
-
|
|
115
|
+
`sidebar.indexLabel`
|
|
116
|
+
|
|
117
|
+
The label of the main index page. Please note if `readme=none` this option has no effect because the index page becomes the root page. Defaults to `Index`.
|
|
118
|
+
|
|
119
|
+
`sidebar.position`
|
|
120
|
+
|
|
121
|
+
The position of the sidebar in the tree.
|
|
122
|
+
|
|
123
|
+
#### `--docsRoot`
|
|
124
|
+
|
|
125
|
+
The Docusaurus docs folder root. Use `./` if no root folder specified. Defaults to `./docs`.
|
|
97
126
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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. |
|
|
127
|
+
```shell
|
|
128
|
+
--docsRoot <path/to/vitepress-docs/>
|
|
129
|
+
```
|
|
104
130
|
|
|
105
131
|
### An example configuration
|
|
106
132
|
|
|
@@ -128,6 +154,21 @@ module.exports = {
|
|
|
128
154
|
};
|
|
129
155
|
```
|
|
130
156
|
|
|
157
|
+
## Frontmatter
|
|
158
|
+
|
|
159
|
+
Additional frontmatter options can be added to the config. Please see [typedoc-plugin-frontmatter](https://github.com/tgreyuk/typedoc-plugin-frontmatter#typedoc-plugin-frontmatter).
|
|
160
|
+
|
|
161
|
+
For example:
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"frontmatterGlobals": {
|
|
166
|
+
"pagination_prev": null,
|
|
167
|
+
"pagination_next": null
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
131
172
|
## Recipes
|
|
132
173
|
|
|
133
174
|
### Sidebar and Navbar
|
|
@@ -190,27 +231,6 @@ A navbar item can be configured in `themeConfig` options in `docusaurus.config.j
|
|
|
190
231
|
|
|
191
232
|
Please see https://docusaurus.io/docs/api/themes/configuration#navbar-items for navbar documentation.
|
|
192
233
|
|
|
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
|
-
```
|
|
213
|
-
|
|
214
234
|
### Multi instance
|
|
215
235
|
|
|
216
236
|
It is possible to build multi TypeDoc instances by passing in multiple configs with unique ids:
|
|
@@ -272,27 +292,6 @@ module.exports = {
|
|
|
272
292
|
};
|
|
273
293
|
```
|
|
274
294
|
|
|
275
|
-
### Monorepo setup
|
|
276
|
-
|
|
277
|
-
`docusaurus.config.js`
|
|
278
|
-
|
|
279
|
-
```js
|
|
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
|
-
```
|
|
295
|
-
|
|
296
295
|
## License
|
|
297
296
|
|
|
298
297
|
[MIT](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/docusaurus-plugin-typedoc/LICENSE)
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,8 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
26
|
+
const path = __importStar(require("path"));
|
|
27
|
+
const typedoc_1 = require("typedoc");
|
|
28
|
+
const options_1 = require("./options");
|
|
29
|
+
const renderer_1 = require("./renderer");
|
|
30
|
+
const apps = [];
|
|
31
|
+
function pluginDocusaurus(context, opts) {
|
|
32
|
+
return {
|
|
33
|
+
name: 'docusaurus-plugin-typedoc',
|
|
34
|
+
async loadContent() {
|
|
35
|
+
if (opts.id && !apps.includes(opts.id)) {
|
|
36
|
+
apps.push(opts.id);
|
|
37
|
+
generateTypedoc(context, opts);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
extendCli(cli) {
|
|
41
|
+
cli
|
|
42
|
+
.command('generate-typedoc')
|
|
43
|
+
.description('(docusaurus-plugin-typedoc) Generate TypeDoc docs independently of the Docusaurus build process.')
|
|
44
|
+
.action(async () => {
|
|
45
|
+
var _a;
|
|
46
|
+
(_a = context.siteConfig) === null || _a === void 0 ? void 0 : _a.plugins.forEach((pluginConfig) => {
|
|
47
|
+
if (pluginConfig && typeof pluginConfig[1] === 'object') {
|
|
48
|
+
generateTypedoc(context, pluginConfig[1]);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
exports.default = pluginDocusaurus;
|
|
56
|
+
async function generateTypedoc(context, opts) {
|
|
57
|
+
const { siteDir } = context;
|
|
58
|
+
const options = (0, options_1.getPluginOptions)(opts);
|
|
59
|
+
const { id, docsRoot, ...optionsPassedToTypeDoc } = options;
|
|
60
|
+
const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
|
|
61
|
+
const app = new typedoc_1.Application();
|
|
62
|
+
(0, options_1.loadOptions)(app);
|
|
63
|
+
(0, renderer_1.loadRenderer)(app);
|
|
64
|
+
await app.bootstrapWithPlugins(optionsPassedToTypeDoc);
|
|
65
|
+
const project = app.convert();
|
|
66
|
+
if (!project) {
|
|
67
|
+
if (app.options.getValue('skipErrorChecking')) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
console.error('[docusaurus-plugin-typedoc] TypeDoc exited with an error. Use the "skipErrorChecking" option to disable TypeDoc error checking.');
|
|
71
|
+
process.exit();
|
|
72
|
+
}
|
|
73
|
+
if (options.watch) {
|
|
74
|
+
app.convertAndWatch(async (project) => {
|
|
75
|
+
await app.generateDocs(project, outputDir);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
await app.generateDocs(project, outputDir);
|
|
80
|
+
}
|
|
81
|
+
}
|
package/dist/models.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TypedocPluginMarkdownOptions } from 'typedoc-plugin-markdown';
|
|
2
|
+
export interface PluginOptions extends TypedocPluginMarkdownOptions {
|
|
3
|
+
id: string;
|
|
4
|
+
docsRoot: string;
|
|
5
|
+
sidebar: SidebarOptions;
|
|
6
|
+
}
|
|
7
|
+
export interface SidebarOptions {
|
|
8
|
+
categoryLabel: string;
|
|
9
|
+
position: number | null;
|
|
10
|
+
autoConfiguration: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SidebarCategory {
|
|
13
|
+
type: string;
|
|
14
|
+
label: string;
|
|
15
|
+
items: SidebarItem[];
|
|
16
|
+
}
|
|
17
|
+
export interface CategoryYamlOptions {
|
|
18
|
+
path: string;
|
|
19
|
+
label: string;
|
|
20
|
+
position: number | null;
|
|
21
|
+
collapsed: boolean;
|
|
22
|
+
}
|
|
23
|
+
export type SidebarItem = SidebarCategory | string;
|
package/dist/options.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Application } from 'typedoc';
|
|
2
|
+
import { PluginOptions } from './models';
|
|
3
|
+
export declare function getPluginOptions(opts: Partial<PluginOptions>): PluginOptions;
|
|
4
|
+
export declare function loadOptions(app: Application): void;
|
package/dist/options.js
CHANGED
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPluginOptions = void 0;
|
|
3
|
+
exports.loadOptions = exports.getPluginOptions = void 0;
|
|
4
|
+
const typedoc_1 = require("typedoc");
|
|
4
5
|
const DEFAULT_PLUGIN_OPTIONS = {
|
|
5
6
|
id: 'default',
|
|
6
7
|
docsRoot: 'docs',
|
|
7
8
|
out: 'api',
|
|
8
|
-
|
|
9
|
+
watch: false,
|
|
10
|
+
plugin: [],
|
|
11
|
+
hideInPageTOC: true,
|
|
12
|
+
hideBreadcrumbs: true,
|
|
13
|
+
hidePageHeader: true,
|
|
14
|
+
includeFileNumberPrefixes: true,
|
|
15
|
+
skipIndexPage: true,
|
|
16
|
+
entryFileName: 'index.md',
|
|
9
17
|
sidebar: {
|
|
10
|
-
fullNames: false,
|
|
11
18
|
categoryLabel: 'API',
|
|
12
|
-
collapsed: true,
|
|
13
|
-
indexLabel: 'Overview',
|
|
14
19
|
position: null,
|
|
15
20
|
autoConfiguration: true,
|
|
16
21
|
},
|
|
17
|
-
hideInPageTOC: true,
|
|
18
|
-
hideBreadcrumbs: true,
|
|
19
|
-
hidePageTitle: false,
|
|
20
|
-
entryDocument: 'index.md',
|
|
21
|
-
plugin: ['none'],
|
|
22
|
-
watch: false,
|
|
23
|
-
theme: 'docusaurus',
|
|
24
|
-
enableFrontmatter: true,
|
|
25
|
-
enableEmojis: true,
|
|
26
22
|
};
|
|
27
|
-
|
|
23
|
+
function getPluginOptions(opts) {
|
|
28
24
|
const options = {
|
|
29
25
|
...DEFAULT_PLUGIN_OPTIONS,
|
|
30
26
|
...opts,
|
|
@@ -34,5 +30,31 @@ const getPluginOptions = (opts) => {
|
|
|
34
30
|
},
|
|
35
31
|
};
|
|
36
32
|
return options;
|
|
37
|
-
}
|
|
33
|
+
}
|
|
38
34
|
exports.getPluginOptions = getPluginOptions;
|
|
35
|
+
function loadOptions(app) {
|
|
36
|
+
app.options.addReader(new typedoc_1.PackageJsonReader());
|
|
37
|
+
app.options.addReader(new typedoc_1.TypeDocReader());
|
|
38
|
+
app.options.addReader(new typedoc_1.TSConfigReader());
|
|
39
|
+
app.options.addDeclaration({
|
|
40
|
+
name: 'sidebar',
|
|
41
|
+
type: typedoc_1.ParameterType.Mixed,
|
|
42
|
+
});
|
|
43
|
+
app.options.addReader(new (class {
|
|
44
|
+
constructor() {
|
|
45
|
+
this.name = 'docusaurus-options';
|
|
46
|
+
this.order = 900;
|
|
47
|
+
this.supportsPackages = false;
|
|
48
|
+
}
|
|
49
|
+
read(container) {
|
|
50
|
+
const plugins = container.getValue('plugin');
|
|
51
|
+
['typedoc-plugin-markdown', 'typedoc-plugin-frontmatter'].forEach((defaultPlugin) => {
|
|
52
|
+
if (!plugins.includes(defaultPlugin)) {
|
|
53
|
+
plugins.push(defaultPlugin);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
container.setValue('plugin', plugins);
|
|
57
|
+
}
|
|
58
|
+
})());
|
|
59
|
+
}
|
|
60
|
+
exports.loadOptions = loadOptions;
|
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadRenderer = void 0;
|
|
4
|
+
const typedoc_1 = require("typedoc");
|
|
5
|
+
const typedoc_plugin_frontmatter_1 = require("typedoc-plugin-frontmatter");
|
|
6
|
+
function loadRenderer(app) {
|
|
7
|
+
app.renderer.on(typedoc_1.PageEvent.END, (page) => {
|
|
8
|
+
if (page.contents) {
|
|
9
|
+
page.contents = page.contents.replace(/\\</g, '<');
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
app.renderer.on(typedoc_plugin_frontmatter_1.FrontmatterEvent.PREPARE_FRONTMATTER, (event) => {
|
|
13
|
+
loadFrontmatter(app, event);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.loadRenderer = loadRenderer;
|
|
17
|
+
function loadFrontmatter(app, event) {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
19
|
+
const renderContext = app.renderer.theme.getRenderContext();
|
|
20
|
+
const sidebar = app.options.getValue('sidebar');
|
|
21
|
+
const isIndexPage = (_a = event.page) === null || _a === void 0 ? void 0 : _a.url.endsWith(renderContext.indexFileName);
|
|
22
|
+
const isReadmePage = (_b = event.page) === null || _b === void 0 ? void 0 : _b.url.endsWith(app.options.getValue('entryFileName'));
|
|
23
|
+
const isPackageModule = event.page.model.kindOf(typedoc_1.ReflectionKind.Module) &&
|
|
24
|
+
!Boolean(((_c = event.page.model) === null || _c === void 0 ? void 0 : _c.parent).groups);
|
|
25
|
+
const model = (_d = event.page) === null || _d === void 0 ? void 0 : _d.model;
|
|
26
|
+
let pluginFrontmatter = {};
|
|
27
|
+
if (sidebar.autoConfiguration) {
|
|
28
|
+
if (!isIndexPage && !isReadmePage) {
|
|
29
|
+
const sidebarLabel = model === null || model === void 0 ? void 0 : model.name;
|
|
30
|
+
pluginFrontmatter = {
|
|
31
|
+
...pluginFrontmatter,
|
|
32
|
+
sidebar_label: sidebarLabel,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (((_e = event.page) === null || _e === void 0 ? void 0 : _e.url) === app.options.getValue('entryFileName')) {
|
|
36
|
+
if (sidebar.categoryLabel) {
|
|
37
|
+
pluginFrontmatter = {
|
|
38
|
+
...pluginFrontmatter,
|
|
39
|
+
sidebar_label: sidebar.categoryLabel,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (sidebar.position !== null && !Number.isNaN(sidebar.position)) {
|
|
43
|
+
pluginFrontmatter = {
|
|
44
|
+
...pluginFrontmatter,
|
|
45
|
+
sidebar_position: sidebar.position,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if ((_f = event.page) === null || _f === void 0 ? void 0 : _f.url.endsWith(app.options.getValue('entryFileName'))) {
|
|
50
|
+
pluginFrontmatter = {
|
|
51
|
+
...pluginFrontmatter,
|
|
52
|
+
hide_table_of_contents: true,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (isPackageModule && isReadmePage) {
|
|
56
|
+
pluginFrontmatter = {
|
|
57
|
+
...pluginFrontmatter,
|
|
58
|
+
sidebar_label: event.page.model.name,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (isPackageModule && isIndexPage && Boolean((_g = event.page.model) === null || _g === void 0 ? void 0 : _g.readme)) {
|
|
62
|
+
pluginFrontmatter = {
|
|
63
|
+
...pluginFrontmatter,
|
|
64
|
+
sidebar_label: 'Index',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
event.frontmatter = {
|
|
69
|
+
...pluginFrontmatter,
|
|
70
|
+
...event.frontmatter,
|
|
71
|
+
};
|
|
72
|
+
}
|
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.10",
|
|
4
4
|
"description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,9 +15,11 @@
|
|
|
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
|
+
},
|
|
18
21
|
"peerDependencies": {
|
|
19
|
-
"typedoc": ">=0.
|
|
20
|
-
"typedoc-plugin-markdown": ">=4.0.0-next.1"
|
|
22
|
+
"typedoc-plugin-markdown": ">=4.0.0-next.12"
|
|
21
23
|
},
|
|
22
24
|
"scripts": {
|
|
23
25
|
"lint": "eslint ./src --ext .ts",
|
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/plugin.d.ts
DELETED
package/dist/plugin.js
DELETED
|
@@ -1,81 +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
|
-
const path = __importStar(require("path"));
|
|
27
|
-
const typedoc_1 = require("typedoc");
|
|
28
|
-
const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
|
|
29
|
-
const options_1 = require("./options");
|
|
30
|
-
const render_1 = require("./render");
|
|
31
|
-
const theme_1 = require("./theme");
|
|
32
|
-
const apps = [];
|
|
33
|
-
function pluginDocusaurus(context, opts) {
|
|
34
|
-
return {
|
|
35
|
-
name: 'docusaurus-plugin-typedoc',
|
|
36
|
-
async loadContent() {
|
|
37
|
-
if (opts.id && !apps.includes(opts.id)) {
|
|
38
|
-
apps.push(opts.id);
|
|
39
|
-
generateTypedoc(context, opts);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
extendCli(cli) {
|
|
43
|
-
cli
|
|
44
|
-
.command('generate-typedoc')
|
|
45
|
-
.description('(docusaurus-plugin-typedoc) Generate TypeDoc docs independently of the Docusaurus build process.')
|
|
46
|
-
.action(async () => {
|
|
47
|
-
var _a;
|
|
48
|
-
(_a = context.siteConfig) === null || _a === void 0 ? void 0 : _a.plugins.forEach((pluginConfig) => {
|
|
49
|
-
if (pluginConfig && typeof pluginConfig[1] === 'object') {
|
|
50
|
-
generateTypedoc(context, pluginConfig[1]);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
exports.default = pluginDocusaurus;
|
|
58
|
-
async function generateTypedoc(context, opts) {
|
|
59
|
-
const { siteDir } = context;
|
|
60
|
-
const options = (0, options_1.getPluginOptions)(opts);
|
|
61
|
-
const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
|
|
62
|
-
if (opts.cleanOutputDir) {
|
|
63
|
-
(0, render_1.removeDir)(outputDir);
|
|
64
|
-
}
|
|
65
|
-
const app = new typedoc_1.Application();
|
|
66
|
-
app.renderer.defineTheme('docusaurus', theme_1.DocusaurusTheme);
|
|
67
|
-
(0, typedoc_plugin_markdown_1.load)(app);
|
|
68
|
-
(0, render_1.bootstrap)(app, options);
|
|
69
|
-
const project = app.convert();
|
|
70
|
-
if (!project) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (options.watch) {
|
|
74
|
-
app.convertAndWatch(async (project) => {
|
|
75
|
-
await app.generateDocs(project, outputDir);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
await app.generateDocs(project, outputDir);
|
|
80
|
-
}
|
|
81
|
-
}
|
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,37 +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
|
-
enableEmojis: boolean;
|
|
22
|
-
}
|
|
23
|
-
export type FrontMatter = Record<string, string | boolean | number | null> | undefined;
|
|
24
|
-
export interface SidebarOptions {
|
|
25
|
-
fullNames?: boolean;
|
|
26
|
-
categoryLabel: string;
|
|
27
|
-
collapsed: boolean;
|
|
28
|
-
indexLabel?: string;
|
|
29
|
-
position: number | null;
|
|
30
|
-
autoConfiguration: boolean;
|
|
31
|
-
}
|
|
32
|
-
export interface SidebarCategory {
|
|
33
|
-
type: string;
|
|
34
|
-
label: string;
|
|
35
|
-
items: SidebarItem[];
|
|
36
|
-
}
|
|
37
|
-
export type SidebarItem = SidebarCategory | string;
|
|
File without changes
|