docusaurus-plugin-typedoc 1.0.0-next.25 → 1.0.0-next.26
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/plugin.d.ts +0 -3
- package/dist/plugin.js +6 -43
- package/dist/sidebar.js +2 -3
- package/dist/theme.js +9 -6
- package/package.json +6 -4
package/dist/plugin.d.ts
CHANGED
|
@@ -3,6 +3,3 @@ export default function pluginDocusaurus(context: any, opts: Partial<PluginOptio
|
|
|
3
3
|
name: string;
|
|
4
4
|
extendCli(cli: any): void;
|
|
5
5
|
}>;
|
|
6
|
-
export declare function writeFileSync(fileName: string, data: string): void;
|
|
7
|
-
export declare function normalizePath(path: string): string;
|
|
8
|
-
export declare function removeDir(path: string): void;
|
package/dist/plugin.js
CHANGED
|
@@ -23,7 +23,6 @@ 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
26
|
const fs = __importStar(require("fs"));
|
|
28
27
|
const path = __importStar(require("path"));
|
|
29
28
|
const typedoc_1 = require("typedoc");
|
|
@@ -45,8 +44,7 @@ async function pluginDocusaurus(context, opts) {
|
|
|
45
44
|
.command('generate-typedoc')
|
|
46
45
|
.description(`[${PLUGIN_NAME}] Generate TypeDoc docs independently of the Docusaurus build process.`)
|
|
47
46
|
.action(async () => {
|
|
48
|
-
|
|
49
|
-
(_a = context.siteConfig) === null || _a === void 0 ? void 0 : _a.plugins.forEach((pluginConfig) => {
|
|
47
|
+
context.siteConfig?.plugins.forEach((pluginConfig) => {
|
|
50
48
|
// Check PluginConfig is typed to [string, PluginOptions]
|
|
51
49
|
if (pluginConfig && typeof pluginConfig[1] === 'object') {
|
|
52
50
|
generateTypedoc(context, pluginConfig[1]);
|
|
@@ -61,33 +59,27 @@ exports.default = pluginDocusaurus;
|
|
|
61
59
|
* Initiates a new typedoc Application bootstraped with plugin options
|
|
62
60
|
*/
|
|
63
61
|
async function generateTypedoc(context, opts) {
|
|
64
|
-
var _a, _b, _c;
|
|
65
62
|
const { siteDir } = context;
|
|
66
63
|
const options = (0, options_1.getPluginOptions)(opts);
|
|
67
64
|
const { id, sidebar, ...optionsPassedToTypeDoc } = options;
|
|
68
65
|
const app = await typedoc_1.Application.bootstrapWithPlugins(optionsPassedToTypeDoc);
|
|
69
66
|
app.renderer.defineTheme('docusaurus', theme_1.DocusuaurusTheme);
|
|
70
67
|
const outputDir = app.options.getValue('out');
|
|
71
|
-
if (
|
|
72
|
-
removeDir(outputDir);
|
|
73
|
-
}
|
|
74
|
-
if (((_b = (_a = context.siteConfig) === null || _a === void 0 ? void 0 : _a.markdown) === null || _b === void 0 ? void 0 : _b.format) !== 'mdx') {
|
|
68
|
+
if (context.siteConfig?.markdown?.format !== 'mdx') {
|
|
75
69
|
app.renderer.on(typedoc_1.PageEvent.END, (event) => {
|
|
76
|
-
|
|
77
|
-
event.contents = (_a = event.contents) === null || _a === void 0 ? void 0 : _a.replace(/\\</g, '<');
|
|
70
|
+
event.contents = event.contents?.replace(/\\</g, '<');
|
|
78
71
|
});
|
|
79
72
|
}
|
|
80
|
-
if (sidebar
|
|
81
|
-
const docsPreset =
|
|
73
|
+
if (sidebar?.autoConfiguration) {
|
|
74
|
+
const docsPreset = context.siteConfig?.presets?.find((preset) => Boolean(preset[1]?.docs));
|
|
82
75
|
app.renderer.postRenderAsyncJobs.push(async (output) => {
|
|
83
|
-
var _a, _b;
|
|
84
76
|
const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
|
|
85
77
|
const baseDir = path
|
|
86
78
|
.relative(siteDir, outputDir)
|
|
87
79
|
.split(path.sep)
|
|
88
80
|
.slice(1)
|
|
89
81
|
.join(path.sep);
|
|
90
|
-
const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, baseDir, sidebar.filteredIds,
|
|
82
|
+
const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, baseDir, sidebar.filteredIds, docsPreset ? docsPreset[1]?.docs?.numberPrefixParser : null);
|
|
91
83
|
fs.writeFileSync(sidebarPath, `// @ts-check
|
|
92
84
|
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
|
93
85
|
const typedocSidebar = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
|
|
@@ -112,32 +104,3 @@ module.exports = typedocSidebar.items;`);
|
|
|
112
104
|
await app.generateDocs(project, outputDir);
|
|
113
105
|
}
|
|
114
106
|
}
|
|
115
|
-
function writeFileSync(fileName, data) {
|
|
116
|
-
fs.mkdirSync(path.dirname(normalizePath(fileName)), { recursive: true });
|
|
117
|
-
fs.writeFileSync(normalizePath(fileName), data);
|
|
118
|
-
}
|
|
119
|
-
exports.writeFileSync = writeFileSync;
|
|
120
|
-
function normalizePath(path) {
|
|
121
|
-
return path.replace(/\\/g, '/');
|
|
122
|
-
}
|
|
123
|
-
exports.normalizePath = normalizePath;
|
|
124
|
-
function removeDir(path) {
|
|
125
|
-
if (fs.existsSync(path)) {
|
|
126
|
-
const files = fs.readdirSync(path);
|
|
127
|
-
if (files.length > 0) {
|
|
128
|
-
files.forEach(function (filename) {
|
|
129
|
-
if (fs.statSync(path + '/' + filename).isDirectory()) {
|
|
130
|
-
removeDir(path + '/' + filename);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
fs.unlinkSync(path + '/' + filename);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
fs.rmdirSync(path);
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
fs.rmdirSync(path);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
exports.removeDir = removeDir;
|
package/dist/sidebar.js
CHANGED
|
@@ -8,14 +8,13 @@ function getSidebar(navigation, basePath, filteredIds = [], numberPrefixParser)
|
|
|
8
8
|
}
|
|
9
9
|
exports.getSidebar = getSidebar;
|
|
10
10
|
function getNavigationItem(navigationItem, basePath, filteredIds, numberPrefixParser) {
|
|
11
|
-
var _a, _b;
|
|
12
11
|
const parsedUrl = numberPrefixParser === false
|
|
13
12
|
? navigationItem.url
|
|
14
|
-
:
|
|
13
|
+
: navigationItem.url?.replace(/\d+\-/g, '');
|
|
15
14
|
const id = navigationItem.url
|
|
16
15
|
? `${basePath}/${parsedUrl}`.replace(/(.*).md/, '$1')
|
|
17
16
|
: null;
|
|
18
|
-
if (
|
|
17
|
+
if (navigationItem.children?.length) {
|
|
19
18
|
return {
|
|
20
19
|
type: 'category',
|
|
21
20
|
label: navigationItem.title,
|
package/dist/theme.js
CHANGED
|
@@ -13,12 +13,15 @@ class DocusuaurusThemeThemeRenderContext extends typedoc_plugin_markdown_1.Markd
|
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
15
|
// adds space around type arguments as docusaurus generates broken links without it in certain use-cases (see https://github.com/facebook/docusaurus/issues/9518)
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
this.partials = {
|
|
17
|
+
...this.partials,
|
|
18
|
+
typeArguments: (typeArguments) => {
|
|
19
|
+
return `\\< ${typeArguments
|
|
20
|
+
.map((typeArgument) => typeArgument instanceof typedoc_1.ReflectionType
|
|
21
|
+
? this.partials.reflectionType(typeArgument)
|
|
22
|
+
: this.partials.someType(typeArgument))
|
|
23
|
+
.join(', ')} \\>`;
|
|
24
|
+
},
|
|
22
25
|
};
|
|
23
26
|
}
|
|
24
27
|
}
|
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.26",
|
|
4
4
|
"description": "A Docusaurus plugin to integrate TypeDoc into a Docusaurus project.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -16,13 +16,15 @@
|
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"typedoc-plugin-markdown": ">=4.0.0-next.
|
|
19
|
+
"typedoc-plugin-markdown": ">=4.0.0-next.44"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"lint": "eslint ./src --ext .ts",
|
|
23
23
|
"prepublishOnly": "npm run lint && npm run build",
|
|
24
24
|
"build": "rm -rf ./dist && tsc",
|
|
25
|
-
"
|
|
25
|
+
"build-and-test": "npm run build && npm run test",
|
|
26
|
+
"test": "jest",
|
|
27
|
+
"test:update": "npm test -- -u"
|
|
26
28
|
},
|
|
27
29
|
"author": "Thomas Grey",
|
|
28
30
|
"license": "MIT",
|
|
@@ -35,6 +37,6 @@
|
|
|
35
37
|
"api"
|
|
36
38
|
],
|
|
37
39
|
"devDependencies": {
|
|
38
|
-
"@docusaurus/types": "^3.
|
|
40
|
+
"@docusaurus/types": "^3.1.1"
|
|
39
41
|
}
|
|
40
42
|
}
|