docusaurus-plugin-typedoc 1.0.0-next.10 → 1.0.0-next.12
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 +7 -9
- package/dist/index.d.ts +1 -2
- package/dist/index.js +11 -1
- package/dist/models.d.ts +4 -16
- package/dist/options.d.ts +1 -2
- package/dist/options.js +5 -11
- package/dist/renderer.js +29 -29
- package/package.json +5 -6
package/README.md
CHANGED
|
@@ -93,7 +93,6 @@ The following typedoc-plugin-markdown options are preset with the plugin.
|
|
|
93
93
|
"hideBreadcrumbs": true,
|
|
94
94
|
"hidePageHeader": true,
|
|
95
95
|
"entryFileName": "index.md",
|
|
96
|
-
"globalsPageStrategy": "skip",
|
|
97
96
|
"includeFileNumberPrefixes": true
|
|
98
97
|
}
|
|
99
98
|
```
|
|
@@ -106,15 +105,19 @@ Options specific to the plugin should also be declared in the same object.
|
|
|
106
105
|
|
|
107
106
|
`sidebar.autoConfiguration`
|
|
108
107
|
|
|
109
|
-
Set to `false` to disable sidebar
|
|
108
|
+
Set to `false` to disable sidebar metadata added to frontmatter. Defaults to `true`.
|
|
110
109
|
|
|
111
110
|
`sidebar.categoryLabel`
|
|
112
111
|
|
|
113
|
-
The sidebar main parent category label. Defaults to
|
|
112
|
+
The sidebar main parent category label. Defaults to entry page title.
|
|
113
|
+
|
|
114
|
+
`sidebar.readmeLabel`
|
|
115
|
+
|
|
116
|
+
The label of the readme page. Defaults to the h1 title of the readme page. Ignored if `readme=none`.
|
|
114
117
|
|
|
115
118
|
`sidebar.indexLabel`
|
|
116
119
|
|
|
117
|
-
The label of the
|
|
120
|
+
The label of the index page. Defaults to the index page title.
|
|
118
121
|
|
|
119
122
|
`sidebar.position`
|
|
120
123
|
|
|
@@ -143,11 +146,6 @@ module.exports = {
|
|
|
143
146
|
|
|
144
147
|
// Plugin options
|
|
145
148
|
out: 'api-xyz',
|
|
146
|
-
sidebar: {
|
|
147
|
-
categoryLabel: 'API XYZ',
|
|
148
|
-
position: 0,
|
|
149
|
-
fullNames: true,
|
|
150
|
-
},
|
|
151
149
|
},
|
|
152
150
|
],
|
|
153
151
|
],
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export default function pluginDocusaurus(context: any, opts: Partial<PluginOptions>): {
|
|
1
|
+
export default function pluginDocusaurus(context: any, opts: Record<string, any>): {
|
|
3
2
|
name: string;
|
|
4
3
|
loadContent(): Promise<void>;
|
|
5
4
|
extendCli(cli: any): void;
|
package/dist/index.js
CHANGED
|
@@ -25,8 +25,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const path = __importStar(require("path"));
|
|
27
27
|
const typedoc_1 = require("typedoc");
|
|
28
|
+
const typedoc_plugin_frontmatter_1 = require("typedoc-plugin-frontmatter");
|
|
29
|
+
const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
|
|
28
30
|
const options_1 = require("./options");
|
|
29
31
|
const renderer_1 = require("./renderer");
|
|
32
|
+
// store list of plugin ids when running multiple instances
|
|
30
33
|
const apps = [];
|
|
31
34
|
function pluginDocusaurus(context, opts) {
|
|
32
35
|
return {
|
|
@@ -44,6 +47,7 @@ function pluginDocusaurus(context, opts) {
|
|
|
44
47
|
.action(async () => {
|
|
45
48
|
var _a;
|
|
46
49
|
(_a = context.siteConfig) === null || _a === void 0 ? void 0 : _a.plugins.forEach((pluginConfig) => {
|
|
50
|
+
// Check PluginConfig is typed to [string, PluginOptions]
|
|
47
51
|
if (pluginConfig && typeof pluginConfig[1] === 'object') {
|
|
48
52
|
generateTypedoc(context, pluginConfig[1]);
|
|
49
53
|
}
|
|
@@ -53,6 +57,9 @@ function pluginDocusaurus(context, opts) {
|
|
|
53
57
|
};
|
|
54
58
|
}
|
|
55
59
|
exports.default = pluginDocusaurus;
|
|
60
|
+
/**
|
|
61
|
+
* Initiates a new typedoc Application bootstraped with plugin options
|
|
62
|
+
*/
|
|
56
63
|
async function generateTypedoc(context, opts) {
|
|
57
64
|
const { siteDir } = context;
|
|
58
65
|
const options = (0, options_1.getPluginOptions)(opts);
|
|
@@ -61,8 +68,11 @@ async function generateTypedoc(context, opts) {
|
|
|
61
68
|
const app = new typedoc_1.Application();
|
|
62
69
|
(0, options_1.loadOptions)(app);
|
|
63
70
|
(0, renderer_1.loadRenderer)(app);
|
|
71
|
+
(0, typedoc_plugin_markdown_1.load)(app);
|
|
72
|
+
(0, typedoc_plugin_frontmatter_1.load)(app);
|
|
64
73
|
await app.bootstrapWithPlugins(optionsPassedToTypeDoc);
|
|
65
74
|
const project = app.convert();
|
|
75
|
+
// if project is undefined typedoc has a problem - error logging will be supplied by typedoc.
|
|
66
76
|
if (!project) {
|
|
67
77
|
if (app.options.getValue('skipErrorChecking')) {
|
|
68
78
|
return;
|
|
@@ -70,7 +80,7 @@ async function generateTypedoc(context, opts) {
|
|
|
70
80
|
console.error('[docusaurus-plugin-typedoc] TypeDoc exited with an error. Use the "skipErrorChecking" option to disable TypeDoc error checking.');
|
|
71
81
|
process.exit();
|
|
72
82
|
}
|
|
73
|
-
if (options.watch) {
|
|
83
|
+
if (app.options.getValue('watch')) {
|
|
74
84
|
app.convertAndWatch(async (project) => {
|
|
75
85
|
await app.generateDocs(project, outputDir);
|
|
76
86
|
});
|
package/dist/models.d.ts
CHANGED
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
export interface PluginOptions extends TypedocPluginMarkdownOptions {
|
|
1
|
+
export interface PluginOptions {
|
|
3
2
|
id: string;
|
|
4
3
|
docsRoot: string;
|
|
5
4
|
sidebar: SidebarOptions;
|
|
6
5
|
}
|
|
7
6
|
export interface SidebarOptions {
|
|
8
|
-
categoryLabel: string;
|
|
9
|
-
position: number | null;
|
|
10
7
|
autoConfiguration: boolean;
|
|
8
|
+
readmeLabel: string;
|
|
9
|
+
indexLabel: string;
|
|
10
|
+
categoryLabel: string;
|
|
11
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,4 +1,3 @@
|
|
|
1
1
|
import { Application } from 'typedoc';
|
|
2
|
-
|
|
3
|
-
export declare function getPluginOptions(opts: Partial<PluginOptions>): PluginOptions;
|
|
2
|
+
export declare function getPluginOptions(opts: Record<string, any>): Record<string, any>;
|
|
4
3
|
export declare function loadOptions(app: Application): void;
|
package/dist/options.js
CHANGED
|
@@ -6,17 +6,13 @@ const DEFAULT_PLUGIN_OPTIONS = {
|
|
|
6
6
|
id: 'default',
|
|
7
7
|
docsRoot: 'docs',
|
|
8
8
|
out: 'api',
|
|
9
|
-
watch: false,
|
|
10
|
-
plugin: [],
|
|
11
9
|
hideInPageTOC: true,
|
|
12
10
|
hideBreadcrumbs: true,
|
|
13
11
|
hidePageHeader: true,
|
|
12
|
+
githubPages: false,
|
|
14
13
|
includeFileNumberPrefixes: true,
|
|
15
|
-
skipIndexPage: true,
|
|
16
14
|
entryFileName: 'index.md',
|
|
17
15
|
sidebar: {
|
|
18
|
-
categoryLabel: 'API',
|
|
19
|
-
position: null,
|
|
20
16
|
autoConfiguration: true,
|
|
21
17
|
},
|
|
22
18
|
};
|
|
@@ -48,12 +44,10 @@ function loadOptions(app) {
|
|
|
48
44
|
}
|
|
49
45
|
read(container) {
|
|
50
46
|
const plugins = container.getValue('plugin');
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
container.setValue('plugin', plugins);
|
|
47
|
+
container.setValue('plugin', plugins === null || plugins === void 0 ? void 0 : plugins.filter((plugin) => ![
|
|
48
|
+
'typedoc-plugin-markdown',
|
|
49
|
+
'typedoc-plugin-frontmatter',
|
|
50
|
+
].includes(plugin)));
|
|
57
51
|
}
|
|
58
52
|
})());
|
|
59
53
|
}
|
package/dist/renderer.js
CHANGED
|
@@ -16,52 +16,52 @@ function loadRenderer(app) {
|
|
|
16
16
|
exports.loadRenderer = loadRenderer;
|
|
17
17
|
function loadFrontmatter(app, event) {
|
|
18
18
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
19
|
-
const
|
|
19
|
+
const hasReadme = !app.options.getValue('readme').endsWith('none');
|
|
20
|
+
const entryPage = app.options.getValue('entryFileName');
|
|
21
|
+
const indexPage = app.options.getValue('indexFileName');
|
|
20
22
|
const sidebar = app.options.getValue('sidebar');
|
|
21
|
-
const
|
|
22
|
-
const
|
|
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;
|
|
23
|
+
const model = (_a = event.page) === null || _a === void 0 ? void 0 : _a.model;
|
|
24
|
+
const sidebarLabel = model === null || model === void 0 ? void 0 : model.name;
|
|
26
25
|
let pluginFrontmatter = {};
|
|
27
26
|
if (sidebar.autoConfiguration) {
|
|
28
|
-
if (
|
|
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')) {
|
|
27
|
+
if (((_b = event.page) === null || _b === void 0 ? void 0 : _b.url) === app.options.getValue('entryFileName')) {
|
|
36
28
|
if (sidebar.categoryLabel) {
|
|
37
29
|
pluginFrontmatter = {
|
|
38
30
|
...pluginFrontmatter,
|
|
39
31
|
sidebar_label: sidebar.categoryLabel,
|
|
40
32
|
};
|
|
41
33
|
}
|
|
42
|
-
|
|
34
|
+
}
|
|
35
|
+
if (hasReadme) {
|
|
36
|
+
if (((_c = event.page) === null || _c === void 0 ? void 0 : _c.url) === entryPage) {
|
|
43
37
|
pluginFrontmatter = {
|
|
44
38
|
...pluginFrontmatter,
|
|
45
|
-
|
|
39
|
+
...(sidebar.readmeLabel && { sidebar_label: sidebar.readmeLabel }),
|
|
40
|
+
sidebar_position: 0,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (((_d = event.page) === null || _d === void 0 ? void 0 : _d.url) === `01-${indexPage}`) {
|
|
44
|
+
pluginFrontmatter = {
|
|
45
|
+
...pluginFrontmatter,
|
|
46
|
+
...(sidebar.indexLabel && { sidebar_label: sidebar.indexLabel }),
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
...pluginFrontmatter,
|
|
58
|
-
sidebar_label: event.page.model.name,
|
|
59
|
-
};
|
|
50
|
+
else {
|
|
51
|
+
if (((_e = event.page) === null || _e === void 0 ? void 0 : _e.url) === entryPage) {
|
|
52
|
+
pluginFrontmatter = {
|
|
53
|
+
...pluginFrontmatter,
|
|
54
|
+
...(sidebar.indexLabel && { sidebar_label: sidebar.indexLabel }),
|
|
55
|
+
sidebar_position: 0,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
60
58
|
}
|
|
61
|
-
|
|
59
|
+
// Add sidebar labels to all pages
|
|
60
|
+
if (!(((_f = event.page) === null || _f === void 0 ? void 0 : _f.url) === entryPage) &&
|
|
61
|
+
!(((_g = event.page) === null || _g === void 0 ? void 0 : _g.url) === `01-${indexPage}`)) {
|
|
62
62
|
pluginFrontmatter = {
|
|
63
63
|
...pluginFrontmatter,
|
|
64
|
-
sidebar_label:
|
|
64
|
+
sidebar_label: sidebarLabel,
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
}
|
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.12",
|
|
4
4
|
"description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -16,17 +16,16 @@
|
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"typedoc-plugin-frontmatter": "
|
|
19
|
+
"typedoc-plugin-frontmatter": ">=0.0.2"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"typedoc-plugin-markdown": ">=4.0.0-next.
|
|
22
|
+
"typedoc-plugin-markdown": ">=4.0.0-next.13"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"lint": "eslint ./src --ext .ts",
|
|
26
|
-
"prepublishOnly": "npm run lint && npm run build
|
|
26
|
+
"prepublishOnly": "npm run lint && npm run build",
|
|
27
27
|
"build": "rm -rf ./dist && tsc",
|
|
28
|
-
"build-and-test": "npm run build && npm run test"
|
|
29
|
-
"test": "jest --colors"
|
|
28
|
+
"build-and-test": "npm run build && npm run test"
|
|
30
29
|
},
|
|
31
30
|
"author": "Thomas Grey",
|
|
32
31
|
"license": "MIT",
|