docusaurus-plugin-typedoc 1.0.0-next.13 → 1.0.0-next.15
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/dist/frontmatter.d.ts +3 -0
- package/dist/frontmatter.js +55 -0
- package/dist/options.d.ts +1 -1
- package/dist/options.js +10 -25
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +17 -12
- package/package.json +7 -8
- package/dist/renderer.d.ts +0 -2
- package/dist/renderer.js +0 -72
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadFrontmatter = void 0;
|
|
4
|
+
const typedoc_plugin_frontmatter_1 = require("typedoc-plugin-frontmatter");
|
|
5
|
+
function loadFrontmatter(app, sidebar) {
|
|
6
|
+
app.renderer.on(typedoc_plugin_frontmatter_1.FrontmatterEvent.PREPARE_FRONTMATTER, (event) => {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f;
|
|
8
|
+
const hasReadme = !app.options.getValue('readme').endsWith('none');
|
|
9
|
+
const entryPage = app.options.getValue('entryFileName');
|
|
10
|
+
const indexPage = app.options.getValue('indexFileName');
|
|
11
|
+
const model = (_a = event.page) === null || _a === void 0 ? void 0 : _a.model;
|
|
12
|
+
const sidebarLabel = model === null || model === void 0 ? void 0 : model.name;
|
|
13
|
+
let pluginFrontmatter = {};
|
|
14
|
+
if (sidebar.autoConfiguration) {
|
|
15
|
+
if (((_b = event.page) === null || _b === void 0 ? void 0 : _b.url) === app.options.getValue('entryFileName')) {
|
|
16
|
+
if (sidebar.categoryLabel) {
|
|
17
|
+
pluginFrontmatter = {
|
|
18
|
+
...pluginFrontmatter,
|
|
19
|
+
sidebar_label: sidebar.categoryLabel,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (hasReadme) {
|
|
24
|
+
if (((_c = event.page) === null || _c === void 0 ? void 0 : _c.url) === entryPage) {
|
|
25
|
+
pluginFrontmatter = {
|
|
26
|
+
...pluginFrontmatter,
|
|
27
|
+
...(sidebar.readmeLabel && {
|
|
28
|
+
sidebar_label: sidebar.readmeLabel,
|
|
29
|
+
}),
|
|
30
|
+
sidebar_position: 0,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (((_d = event.page) === null || _d === void 0 ? void 0 : _d.url) === `01-${indexPage}`) {
|
|
34
|
+
pluginFrontmatter = {
|
|
35
|
+
...pluginFrontmatter,
|
|
36
|
+
...(sidebar.indexLabel && { sidebar_label: sidebar.indexLabel }),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Add sidebar labels to all pages
|
|
41
|
+
if (!(((_e = event.page) === null || _e === void 0 ? void 0 : _e.url) === entryPage) &&
|
|
42
|
+
!(((_f = event.page) === null || _f === void 0 ? void 0 : _f.url) === `01-${indexPage}`)) {
|
|
43
|
+
pluginFrontmatter = {
|
|
44
|
+
...pluginFrontmatter,
|
|
45
|
+
sidebar_label: sidebarLabel,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
event.frontmatter = {
|
|
50
|
+
...pluginFrontmatter,
|
|
51
|
+
...event.frontmatter,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.loadFrontmatter = loadFrontmatter;
|
package/dist/options.d.ts
CHANGED
package/dist/options.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const typedoc_1 = require("typedoc");
|
|
3
|
+
exports.setOptions = exports.getPluginOptions = void 0;
|
|
5
4
|
const DEFAULT_PLUGIN_OPTIONS = {
|
|
6
5
|
id: 'default',
|
|
7
6
|
docsRoot: 'docs',
|
|
@@ -15,6 +14,7 @@ const DEFAULT_PLUGIN_OPTIONS = {
|
|
|
15
14
|
sidebar: {
|
|
16
15
|
autoConfiguration: true,
|
|
17
16
|
},
|
|
17
|
+
plugin: ['typedoc-plugin-markdown', 'typedoc-plugin-frontmatter'],
|
|
18
18
|
};
|
|
19
19
|
function getPluginOptions(opts) {
|
|
20
20
|
const options = {
|
|
@@ -24,31 +24,16 @@ function getPluginOptions(opts) {
|
|
|
24
24
|
...DEFAULT_PLUGIN_OPTIONS.sidebar,
|
|
25
25
|
...opts.sidebar,
|
|
26
26
|
},
|
|
27
|
+
plugin: [
|
|
28
|
+
...new Set([...DEFAULT_PLUGIN_OPTIONS.plugin, ...(opts.plugin || [])]),
|
|
29
|
+
],
|
|
27
30
|
};
|
|
28
31
|
return options;
|
|
29
32
|
}
|
|
30
33
|
exports.getPluginOptions = getPluginOptions;
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
app.options.addDeclaration({
|
|
36
|
-
name: 'sidebar',
|
|
37
|
-
type: typedoc_1.ParameterType.Mixed,
|
|
38
|
-
});
|
|
39
|
-
app.options.addReader(new (class {
|
|
40
|
-
constructor() {
|
|
41
|
-
this.name = 'docusaurus-options';
|
|
42
|
-
this.order = 900;
|
|
43
|
-
this.supportsPackages = false;
|
|
44
|
-
}
|
|
45
|
-
read(container) {
|
|
46
|
-
const plugins = container.getValue('plugin');
|
|
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)));
|
|
51
|
-
}
|
|
52
|
-
})());
|
|
34
|
+
function setOptions(app, options) {
|
|
35
|
+
for (const [key, val] of Object.entries(options)) {
|
|
36
|
+
app.options.setValue(key, val);
|
|
37
|
+
}
|
|
53
38
|
}
|
|
54
|
-
exports.
|
|
39
|
+
exports.setOptions = setOptions;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -4,3 +4,5 @@ export default function pluginDocusaurus(context: any, opts: Partial<PluginOptio
|
|
|
4
4
|
loadContent(): Promise<void>;
|
|
5
5
|
extendCli(cli: any): void;
|
|
6
6
|
};
|
|
7
|
+
export declare function writeFileSync(fileName: string, data: string): void;
|
|
8
|
+
export declare function normalizePath(path: string): string;
|
package/dist/plugin.js
CHANGED
|
@@ -23,12 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.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
|
|
29
|
-
const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
|
|
30
|
+
const frontmatter_1 = require("./frontmatter");
|
|
30
31
|
const options_1 = require("./options");
|
|
31
|
-
const renderer_1 = require("./renderer");
|
|
32
32
|
// store list of plugin ids when running multiple instances
|
|
33
33
|
const apps = [];
|
|
34
34
|
function pluginDocusaurus(context, opts) {
|
|
@@ -37,7 +37,7 @@ function pluginDocusaurus(context, opts) {
|
|
|
37
37
|
async loadContent() {
|
|
38
38
|
if (opts.id && !apps.includes(opts.id)) {
|
|
39
39
|
apps.push(opts.id);
|
|
40
|
-
generateTypedoc(context, opts);
|
|
40
|
+
await generateTypedoc(context, opts);
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
extendCli(cli) {
|
|
@@ -63,15 +63,11 @@ exports.default = pluginDocusaurus;
|
|
|
63
63
|
async function generateTypedoc(context, opts) {
|
|
64
64
|
const { siteDir } = context;
|
|
65
65
|
const options = (0, options_1.getPluginOptions)(opts);
|
|
66
|
-
const { id, docsRoot, ...optionsPassedToTypeDoc } = options;
|
|
66
|
+
const { id, docsRoot, sidebar, ...optionsPassedToTypeDoc } = options;
|
|
67
67
|
const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
|
|
68
|
-
const app =
|
|
69
|
-
(0,
|
|
70
|
-
|
|
71
|
-
(0, typedoc_plugin_markdown_1.load)(app);
|
|
72
|
-
(0, typedoc_plugin_frontmatter_1.load)(app);
|
|
73
|
-
await app.bootstrapWithPlugins(optionsPassedToTypeDoc);
|
|
74
|
-
const project = app.convert();
|
|
68
|
+
const app = await typedoc_1.Application.bootstrapWithPlugins(optionsPassedToTypeDoc);
|
|
69
|
+
(0, frontmatter_1.loadFrontmatter)(app, options.sidebar);
|
|
70
|
+
const project = await app.convert();
|
|
75
71
|
// if project is undefined typedoc has a problem - error logging will be supplied by typedoc.
|
|
76
72
|
if (!project) {
|
|
77
73
|
if (app.options.getValue('skipErrorChecking')) {
|
|
@@ -89,3 +85,12 @@ async function generateTypedoc(context, opts) {
|
|
|
89
85
|
await app.generateDocs(project, outputDir);
|
|
90
86
|
}
|
|
91
87
|
}
|
|
88
|
+
function writeFileSync(fileName, data) {
|
|
89
|
+
fs.mkdirSync(path.dirname(normalizePath(fileName)), { recursive: true });
|
|
90
|
+
fs.writeFileSync(normalizePath(fileName), data);
|
|
91
|
+
}
|
|
92
|
+
exports.writeFileSync = writeFileSync;
|
|
93
|
+
function normalizePath(path) {
|
|
94
|
+
return path.replace(/\\/g, '/');
|
|
95
|
+
}
|
|
96
|
+
exports.normalizePath = normalizePath;
|
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.15",
|
|
4
4
|
"description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -15,17 +15,13 @@
|
|
|
15
15
|
"directory": "packages/docusaurus-plugin-typedoc"
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"typedoc-plugin-frontmatter": ">=0.0.2"
|
|
20
|
-
},
|
|
21
18
|
"peerDependencies": {
|
|
22
|
-
"typedoc-plugin-markdown": ">=4.0.0-next.
|
|
19
|
+
"typedoc-plugin-markdown": ">=4.0.0-next.19"
|
|
23
20
|
},
|
|
24
21
|
"scripts": {
|
|
25
22
|
"lint": "eslint ./src --ext .ts",
|
|
26
23
|
"prepublishOnly": "npm run lint && npm run build",
|
|
27
|
-
"build": "rm -rf ./dist && tsc"
|
|
28
|
-
"build-and-test": "npm run build && npm run test"
|
|
24
|
+
"build": "rm -rf ./dist && tsc"
|
|
29
25
|
},
|
|
30
26
|
"author": "Thomas Grey",
|
|
31
27
|
"license": "MIT",
|
|
@@ -36,5 +32,8 @@
|
|
|
36
32
|
"markdown",
|
|
37
33
|
"typescript",
|
|
38
34
|
"api"
|
|
39
|
-
]
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@docusaurus/types": "^2.4.1"
|
|
38
|
+
}
|
|
40
39
|
}
|
package/dist/renderer.d.ts
DELETED
package/dist/renderer.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
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 hasReadme = !app.options.getValue('readme').endsWith('none');
|
|
20
|
-
const entryPage = app.options.getValue('entryFileName');
|
|
21
|
-
const indexPage = app.options.getValue('indexFileName');
|
|
22
|
-
const sidebar = app.options.getValue('sidebar');
|
|
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;
|
|
25
|
-
let pluginFrontmatter = {};
|
|
26
|
-
if (sidebar.autoConfiguration) {
|
|
27
|
-
if (((_b = event.page) === null || _b === void 0 ? void 0 : _b.url) === app.options.getValue('entryFileName')) {
|
|
28
|
-
if (sidebar.categoryLabel) {
|
|
29
|
-
pluginFrontmatter = {
|
|
30
|
-
...pluginFrontmatter,
|
|
31
|
-
sidebar_label: sidebar.categoryLabel,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (hasReadme) {
|
|
36
|
-
if (((_c = event.page) === null || _c === void 0 ? void 0 : _c.url) === entryPage) {
|
|
37
|
-
pluginFrontmatter = {
|
|
38
|
-
...pluginFrontmatter,
|
|
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 }),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
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
|
-
}
|
|
58
|
-
}
|
|
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
|
-
pluginFrontmatter = {
|
|
63
|
-
...pluginFrontmatter,
|
|
64
|
-
sidebar_label: sidebarLabel,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
event.frontmatter = {
|
|
69
|
-
...pluginFrontmatter,
|
|
70
|
-
...event.frontmatter,
|
|
71
|
-
};
|
|
72
|
-
}
|