docusaurus-plugin-typedoc 0.17.4 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/options.js +2 -0
- package/dist/plugin.d.ts +3 -1
- package/dist/plugin.js +38 -22
- package/dist/theme.d.ts +0 -1
- package/dist/theme.js +27 -29
- package/dist/types.d.ts +4 -2
- package/package.json +42 -43
package/README.md
CHANGED
|
@@ -101,6 +101,7 @@ Options specific to the plugin should also be declared in the same object.
|
|
|
101
101
|
| `includeExtension` | `true` | Determines whether to preserve the `.md` extension in relative links. `true` is recommended as per [Docusaurus documentation](https://docusaurus.io/docs/docs-markdown-features#referencing-other-documents) |
|
|
102
102
|
| `frontmatter` | `null` | Additional frontmatter options object. See [Frontmatter](#frontmatter). |
|
|
103
103
|
| `sidebar.categoryLabel` | `API` | The sidebar parent category label. |
|
|
104
|
+
| `sidebar.collapsed` | `true` | Whether the parent category is initially collapsed |
|
|
104
105
|
| `sidebar.fullNames` | `false` | Display full names with module path. |
|
|
105
106
|
| `sidebar.position` | `auto` | The position of the sidebar in the tree. |
|
|
106
107
|
|
|
@@ -121,6 +122,7 @@ module.exports = {
|
|
|
121
122
|
out: 'api-xyz',
|
|
122
123
|
sidebar: {
|
|
123
124
|
categoryLabel: 'API XYZ',
|
|
125
|
+
collapsed: false,
|
|
124
126
|
position: 0,
|
|
125
127
|
fullNames: true,
|
|
126
128
|
},
|
|
@@ -153,7 +155,7 @@ module.exports = {
|
|
|
153
155
|
|
|
154
156
|
2. Alternatively, if you wish to manually control other parts of your sidebar you can use a slice for the TypeDoc sidebar.
|
|
155
157
|
|
|
156
|
-
> note: `sidebar.categoryLabel` and `sidebar.position` options are ignored with this implementation)
|
|
158
|
+
> note: `sidebar.categoryLabel`, `sidebar.collapsed`, and `sidebar.position` options are ignored with this implementation)
|
|
157
159
|
|
|
158
160
|
```js
|
|
159
161
|
module.exports = {
|
package/dist/options.js
CHANGED
|
@@ -9,9 +9,11 @@ const DEFAULT_PLUGIN_OPTIONS = {
|
|
|
9
9
|
sidebar: {
|
|
10
10
|
fullNames: false,
|
|
11
11
|
categoryLabel: 'API',
|
|
12
|
+
collapsed: true,
|
|
12
13
|
indexLabel: undefined,
|
|
13
14
|
readmeLabel: 'Readme',
|
|
14
15
|
position: null,
|
|
16
|
+
autoConfiguration: true,
|
|
15
17
|
},
|
|
16
18
|
hideInPageTOC: true,
|
|
17
19
|
hideBreadcrumbs: true,
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { LoadContext } from '@docusaurus/types';
|
|
1
2
|
import { PluginOptions } from './types';
|
|
2
|
-
export default function pluginDocusaurus(context:
|
|
3
|
+
export default function pluginDocusaurus(context: LoadContext, opts: Partial<PluginOptions>): {
|
|
3
4
|
name: string;
|
|
4
5
|
loadContent(): Promise<void>;
|
|
6
|
+
extendCli(cli: any): void;
|
|
5
7
|
};
|
package/dist/plugin.js
CHANGED
|
@@ -36,30 +36,46 @@ function pluginDocusaurus(context, opts) {
|
|
|
36
36
|
async loadContent() {
|
|
37
37
|
if (opts.id && !apps.includes(opts.id)) {
|
|
38
38
|
apps.push(opts.id);
|
|
39
|
-
|
|
40
|
-
const options = (0, options_1.getPluginOptions)(opts);
|
|
41
|
-
const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
|
|
42
|
-
if (opts.cleanOutputDir) {
|
|
43
|
-
(0, render_1.removeDir)(outputDir);
|
|
44
|
-
}
|
|
45
|
-
const app = new typedoc_1.Application();
|
|
46
|
-
app.renderer.defineTheme('docusaurus', theme_1.DocusaurusTheme);
|
|
47
|
-
(0, typedoc_plugin_markdown_1.load)(app);
|
|
48
|
-
(0, render_1.bootstrap)(app, options);
|
|
49
|
-
const project = app.convert();
|
|
50
|
-
if (!project) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (options.watch) {
|
|
54
|
-
app.convertAndWatch(async (project) => {
|
|
55
|
-
await app.generateDocs(project, outputDir);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
await app.generateDocs(project, outputDir);
|
|
60
|
-
}
|
|
39
|
+
generateTypedoc(context, opts);
|
|
61
40
|
}
|
|
62
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
|
+
},
|
|
63
55
|
};
|
|
64
56
|
}
|
|
65
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/theme.d.ts
CHANGED
|
@@ -16,7 +16,6 @@ export declare class DocusaurusTheme extends MarkdownTheme {
|
|
|
16
16
|
getSidebarPosition(page: PageEvent<DeclarationReflection>): "0.5" | "0" | null;
|
|
17
17
|
getId(page: PageEvent): string;
|
|
18
18
|
getTitle(page: PageEvent): any;
|
|
19
|
-
getSlug(): string;
|
|
20
19
|
get mappings(): {
|
|
21
20
|
kind: ReflectionKind[];
|
|
22
21
|
isLeaf: boolean;
|
package/dist/theme.js
CHANGED
|
@@ -30,11 +30,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.DocusaurusTheme = void 0;
|
|
33
|
-
const typedoc_1 = require("typedoc");
|
|
34
33
|
const fs = __importStar(require("fs"));
|
|
35
|
-
const theme_1 = require("typedoc-plugin-markdown/dist/theme");
|
|
36
|
-
const groups_1 = require("typedoc-plugin-markdown/dist/groups");
|
|
37
34
|
const path = __importStar(require("path"));
|
|
35
|
+
const typedoc_1 = require("typedoc");
|
|
36
|
+
const groups_1 = require("typedoc-plugin-markdown/dist/groups");
|
|
37
|
+
const theme_1 = require("typedoc-plugin-markdown/dist/theme");
|
|
38
38
|
const front_matter_1 = require("typedoc-plugin-markdown/dist/utils/front-matter");
|
|
39
39
|
const CATEGORY_POSITION = {
|
|
40
40
|
[typedoc_1.ReflectionKind.Module]: 1,
|
|
@@ -69,14 +69,16 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
onRendererEnd(renderer) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
if (this.sidebar.autoConfiguration) {
|
|
73
|
+
writeCategoryYaml(renderer.outputDirectory, this.sidebar.categoryLabel, this.sidebar.position, this.sidebar.collapsed);
|
|
74
|
+
Object.keys(groupUrlsByKind(this.getUrls(renderer.project))).forEach((group) => {
|
|
75
|
+
const kind = parseInt(group);
|
|
76
|
+
const mapping = this.mappings.find((mapping) => mapping.kind.includes(kind));
|
|
77
|
+
if (mapping) {
|
|
78
|
+
writeCategoryYaml(renderer.outputDirectory + '/' + mapping.directory, (0, groups_1.getKindPlural)(kind), CATEGORY_POSITION[kind], true);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
80
82
|
}
|
|
81
83
|
getYamlItems(page) {
|
|
82
84
|
const pageId = this.getId(page);
|
|
@@ -87,14 +89,16 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
|
|
|
87
89
|
id: pageId,
|
|
88
90
|
title: pageTitle,
|
|
89
91
|
};
|
|
90
|
-
if (page.url === this.entryDocument) {
|
|
91
|
-
items = { ...items, slug: this.
|
|
92
|
-
}
|
|
93
|
-
if (sidebarLabel && sidebarLabel !== pageTitle) {
|
|
94
|
-
items = { ...items, sidebar_label: sidebarLabel };
|
|
92
|
+
if (page.url === this.entryDocument && this.indexSlug) {
|
|
93
|
+
items = { ...items, slug: this.indexSlug };
|
|
95
94
|
}
|
|
96
|
-
if (
|
|
97
|
-
|
|
95
|
+
if (this.sidebar.autoConfiguration) {
|
|
96
|
+
if (sidebarLabel && sidebarLabel !== pageTitle) {
|
|
97
|
+
items = { ...items, sidebar_label: sidebarLabel };
|
|
98
|
+
}
|
|
99
|
+
if (sidebarPosition) {
|
|
100
|
+
items = { ...items, sidebar_position: parseFloat(sidebarPosition) };
|
|
101
|
+
}
|
|
98
102
|
}
|
|
99
103
|
if (page.url === page.project.url && this.entryPoints.length > 1) {
|
|
100
104
|
items = { ...items, hide_table_of_contents: true };
|
|
@@ -109,7 +113,7 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
|
|
|
109
113
|
}
|
|
110
114
|
getSidebarLabel(page) {
|
|
111
115
|
const indexLabel = this.sidebar.indexLabel ||
|
|
112
|
-
(this.entryPoints.length > 1 ? 'Table of
|
|
116
|
+
(this.entryPoints.length > 1 ? 'Table of Contents' : 'Exports');
|
|
113
117
|
if (page.url === this.entryDocument) {
|
|
114
118
|
return page.url === page.project.url
|
|
115
119
|
? indexLabel
|
|
@@ -142,15 +146,6 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
|
|
|
142
146
|
}
|
|
143
147
|
return (0, front_matter_1.getPageTitle)(page);
|
|
144
148
|
}
|
|
145
|
-
getSlug() {
|
|
146
|
-
if (this.indexSlug) {
|
|
147
|
-
return this.indexSlug;
|
|
148
|
-
}
|
|
149
|
-
if (this.out === process.cwd()) {
|
|
150
|
-
return '/';
|
|
151
|
-
}
|
|
152
|
-
return `/${path.relative(process.cwd(), this.out).replace(/\\/g, '/')}/`;
|
|
153
|
-
}
|
|
154
149
|
get mappings() {
|
|
155
150
|
return super.mappings.map((mapping) => {
|
|
156
151
|
if (mapping.kind.includes(typedoc_1.ReflectionKind.Namespace)) {
|
|
@@ -182,11 +177,14 @@ __decorate([
|
|
|
182
177
|
(0, typedoc_1.BindOption)('frontmatter')
|
|
183
178
|
], DocusaurusTheme.prototype, "frontmatter", void 0);
|
|
184
179
|
exports.DocusaurusTheme = DocusaurusTheme;
|
|
185
|
-
const writeCategoryYaml = (categoryPath, label, position) => {
|
|
180
|
+
const writeCategoryYaml = (categoryPath, label, position, collapsed) => {
|
|
186
181
|
const yaml = [`label: "${label}"`];
|
|
187
182
|
if (position !== null) {
|
|
188
183
|
yaml.push(`position: ${position}`);
|
|
189
184
|
}
|
|
185
|
+
if (!collapsed) {
|
|
186
|
+
yaml.push(`collapsed: false`);
|
|
187
|
+
}
|
|
190
188
|
if (fs.existsSync(categoryPath)) {
|
|
191
189
|
fs.writeFileSync(categoryPath + '/_category_.yml', yaml.join('\n'));
|
|
192
190
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -21,17 +21,19 @@ export interface PluginOptions {
|
|
|
21
21
|
theme?: string;
|
|
22
22
|
frontmatter: FrontMatter;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
24
|
+
export type FrontMatter = Record<string, string | boolean | number | null> | undefined;
|
|
25
25
|
export interface SidebarOptions {
|
|
26
26
|
fullNames?: boolean;
|
|
27
27
|
categoryLabel: string;
|
|
28
|
+
collapsed: boolean;
|
|
28
29
|
indexLabel?: string;
|
|
29
30
|
readmeLabel?: string;
|
|
30
31
|
position: number | null;
|
|
32
|
+
autoConfiguration: boolean;
|
|
31
33
|
}
|
|
32
34
|
export interface SidebarCategory {
|
|
33
35
|
type: string;
|
|
34
36
|
label: string;
|
|
35
37
|
items: SidebarItem[];
|
|
36
38
|
}
|
|
37
|
-
export
|
|
39
|
+
export type SidebarItem = SidebarCategory | string;
|
package/package.json
CHANGED
|
@@ -1,43 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "docusaurus-plugin-typedoc",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist/"
|
|
8
|
-
],
|
|
9
|
-
"bugs": {
|
|
10
|
-
"url": "https://github.com/tgreyuk/typedoc-plugin-markdown/issues"
|
|
11
|
-
},
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/tgreyuk/typedoc-plugin-markdown.git",
|
|
15
|
-
"directory": "packages/docusaurus-plugin-typedoc"
|
|
16
|
-
},
|
|
17
|
-
"homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
|
|
18
|
-
"peerDependencies": {
|
|
19
|
-
"typedoc": ">=0.
|
|
20
|
-
"typedoc-plugin-markdown": ">=3.
|
|
21
|
-
},
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"test
|
|
30
|
-
"test": "jest --colors"
|
|
31
|
-
},
|
|
32
|
-
"author": "Thomas Grey",
|
|
33
|
-
"license": "MIT",
|
|
34
|
-
"keywords": [
|
|
35
|
-
"docusaurus",
|
|
36
|
-
"typedoc",
|
|
37
|
-
"plugin",
|
|
38
|
-
"markdown",
|
|
39
|
-
"typescript",
|
|
40
|
-
"api"
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "docusaurus-plugin-typedoc",
|
|
3
|
+
"version": "0.18.0",
|
|
4
|
+
"description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/"
|
|
8
|
+
],
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/tgreyuk/typedoc-plugin-markdown/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/tgreyuk/typedoc-plugin-markdown.git",
|
|
15
|
+
"directory": "packages/docusaurus-plugin-typedoc"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"typedoc": ">=0.23.0",
|
|
20
|
+
"typedoc-plugin-markdown": ">=3.13.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typedoc-plugin-markdown": "^3.13.0"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"lint": "eslint ./src --ext .ts",
|
|
27
|
+
"prepublishOnly": "yarn run lint && yarn run build && yarn run test",
|
|
28
|
+
"build": "rm -rf ./dist && tsc",
|
|
29
|
+
"build-and-test": "yarn run build && yarn run test",
|
|
30
|
+
"test": "jest --colors"
|
|
31
|
+
},
|
|
32
|
+
"author": "Thomas Grey",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"keywords": [
|
|
35
|
+
"docusaurus",
|
|
36
|
+
"typedoc",
|
|
37
|
+
"plugin",
|
|
38
|
+
"markdown",
|
|
39
|
+
"typescript",
|
|
40
|
+
"api"
|
|
41
|
+
]
|
|
42
|
+
}
|