docusaurus-plugin-typedoc 1.0.1 → 1.0.3
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 +0 -6
- package/dist/models.d.ts +1 -1
- package/dist/options/index.d.ts +7 -0
- package/dist/options/index.js +33 -0
- package/dist/options/presets.d.ts +1 -2
- package/dist/options/presets.js +2 -1
- package/dist/options.js +4 -7
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +12 -10
- package/dist/sidebar.js +1 -2
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +22 -0
- package/dist/{options/option-types.d.ts → types/options.d.ts} +0 -10
- package/dist/types/options.js +2 -0
- package/dist/utils/adjust-basedir.d.ts +4 -0
- package/dist/utils/adjust-basedir.js +54 -0
- package/package.json +4 -4
- package/dist/options/option-types.js +0 -3
package/README.md
CHANGED
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
> A Docusaurus plugin to integrate TypeDoc ( + typedoc-plugin-markdown ) into a Docusaurus project.
|
|
6
6
|
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```shell
|
|
10
|
-
npm install docusaurus-plugin-typedoc --save-dev
|
|
11
|
-
```
|
|
12
|
-
|
|
13
7
|
## Documentation
|
|
14
8
|
|
|
15
9
|
Please visit the [https://typedoc-plugin-markdown.org/plugins/docusaurus](https://typedoc-plugin-markdown.org/plugins/docusaurus) for comprehensive documentation, including options and usage guides.
|
package/dist/models.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginOptions as TypedocPluginMarkdownOptions } from 'typedoc-plugin-markdown';
|
|
2
|
-
import { PluginOptions as DocusaurusOptions } from './
|
|
2
|
+
import { PluginOptions as DocusaurusOptions } from './types';
|
|
3
3
|
export interface PluginOptions extends TypedocPluginMarkdownOptions, DocusaurusOptions {
|
|
4
4
|
id: string;
|
|
5
5
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* All plugin types are exported from this module.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
+
if (mod && mod.__esModule) return mod;
|
|
25
|
+
var result = {};
|
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
+
__setModuleDefault(result, mod);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.presets = exports.declarations = void 0;
|
|
32
|
+
exports.declarations = __importStar(require("./declarations"));
|
|
33
|
+
exports.presets = __importStar(require("./presets"));
|
package/dist/options/presets.js
CHANGED
package/dist/options.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
|
|
3
|
+
exports.DEFAULT_SIDEBAR_OPTIONS = void 0;
|
|
4
|
+
exports.getPluginOptions = getPluginOptions;
|
|
5
|
+
const presets_1 = require("./options/presets");
|
|
8
6
|
exports.DEFAULT_SIDEBAR_OPTIONS = {
|
|
9
7
|
autoConfiguration: true,
|
|
10
8
|
pretty: false,
|
|
11
9
|
};
|
|
12
10
|
const DEFAULT_PLUGIN_OPTIONS = {
|
|
13
|
-
...presets_1.
|
|
11
|
+
...presets_1.presets,
|
|
14
12
|
id: 'default',
|
|
15
13
|
sidebar: {
|
|
16
14
|
...exports.DEFAULT_SIDEBAR_OPTIONS,
|
|
@@ -30,4 +28,3 @@ function getPluginOptions(opts) {
|
|
|
30
28
|
};
|
|
31
29
|
return options;
|
|
32
30
|
}
|
|
33
|
-
exports.getPluginOptions = getPluginOptions;
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -23,12 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.default = pluginDocusaurus;
|
|
26
27
|
const fs = __importStar(require("fs"));
|
|
27
28
|
const path = __importStar(require("path"));
|
|
28
29
|
const typedoc_1 = require("typedoc");
|
|
29
30
|
const options_1 = require("./options");
|
|
30
31
|
const options = __importStar(require("./options/declarations"));
|
|
31
32
|
const sidebar_1 = require("./sidebar");
|
|
33
|
+
const adjust_basedir_1 = require("./utils/adjust-basedir");
|
|
32
34
|
// store list of plugin ids when running multiple instances
|
|
33
35
|
const apps = [];
|
|
34
36
|
async function pluginDocusaurus(context, opts) {
|
|
@@ -54,7 +56,6 @@ async function pluginDocusaurus(context, opts) {
|
|
|
54
56
|
},
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
|
-
exports.default = pluginDocusaurus;
|
|
58
59
|
/**
|
|
59
60
|
* Initiates a new typedoc Application bootstrapped with plugin options
|
|
60
61
|
*/
|
|
@@ -62,30 +63,31 @@ async function generateTypedoc(context, opts) {
|
|
|
62
63
|
const { siteDir } = context;
|
|
63
64
|
const pluginOptions = (0, options_1.getPluginOptions)(opts);
|
|
64
65
|
const { id, sidebar, ...optionsPassedToTypeDoc } = pluginOptions;
|
|
65
|
-
const
|
|
66
|
+
const outputDir = path.join(siteDir, pluginOptions.out);
|
|
67
|
+
if (!fs.existsSync(outputDir)) {
|
|
68
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
69
|
+
}
|
|
70
|
+
const app = (await typedoc_1.Application.bootstrapWithPlugins(optionsPassedToTypeDoc));
|
|
66
71
|
Object.entries(options).forEach(([name, option]) => {
|
|
67
72
|
app.options.addDeclaration({
|
|
68
73
|
name,
|
|
69
74
|
...option,
|
|
70
75
|
});
|
|
71
76
|
});
|
|
72
|
-
// attempt to handle docusaurus linkify bug https://github.com/facebook/docusaurus/issues/9048
|
|
73
|
-
app.renderer.on(typedoc_1.PageEvent.END, (event) => {
|
|
74
|
-
event.contents = event.contents
|
|
75
|
-
?.replace(/\)\.\[/g, ') . [')
|
|
76
|
-
.replace(/\\<\[/g, ' \\<[');
|
|
77
|
-
});
|
|
78
|
-
const outputDir = app.options.getValue('out');
|
|
79
77
|
if (sidebar?.autoConfiguration) {
|
|
80
78
|
const docsPreset = context.siteConfig?.presets?.find((preset) => Boolean(preset[1]?.docs));
|
|
81
79
|
app.renderer.postRenderAsyncJobs.push(async (output) => {
|
|
82
80
|
if (output.navigation) {
|
|
83
81
|
const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
|
|
84
|
-
|
|
82
|
+
let baseDir = path
|
|
85
83
|
.relative(siteDir, outputDir)
|
|
86
84
|
.split(path.sep)
|
|
87
85
|
.slice(1)
|
|
88
86
|
.join('/');
|
|
87
|
+
const docsPresetPath = docsPreset ? docsPreset[1]?.docs?.path : null;
|
|
88
|
+
if (Boolean(docsPresetPath)) {
|
|
89
|
+
baseDir = (0, adjust_basedir_1.adjustBaseDirectory)(baseDir, docsPresetPath);
|
|
90
|
+
}
|
|
89
91
|
const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, baseDir, docsPreset ? docsPreset[1]?.docs?.numberPrefixParser : null);
|
|
90
92
|
fs.writeFileSync(sidebarPath, `// @ts-check
|
|
91
93
|
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
package/dist/sidebar.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSidebar =
|
|
3
|
+
exports.getSidebar = getSidebar;
|
|
4
4
|
function getSidebar(navigation, basePath, numberPrefixParser) {
|
|
5
5
|
return navigation
|
|
6
6
|
.map((navigationItem) => getNavigationItem(navigationItem, basePath, numberPrefixParser))
|
|
7
7
|
.filter((navItem) => Boolean(navItem));
|
|
8
8
|
}
|
|
9
|
-
exports.getSidebar = getSidebar;
|
|
10
9
|
function getNavigationItem(navigationItem, basePath, numberPrefixParser) {
|
|
11
10
|
const parsedUrl = numberPrefixParser === false
|
|
12
11
|
? navigationItem.path
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* All plugin types are exported from this module.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
__exportStar(require("./options"), exports);
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import { ManuallyValidatedOption } from 'typedoc';
|
|
2
|
-
declare module 'typedoc' {
|
|
3
|
-
interface TypeDocOptionMap {
|
|
4
|
-
sidebar: ManuallyValidatedOption<Sidebar>;
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
1
|
/**
|
|
8
2
|
* Describes the options declared by the plugin.
|
|
9
|
-
*
|
|
10
|
-
* @category Options
|
|
11
3
|
*/
|
|
12
4
|
export interface PluginOptions {
|
|
13
5
|
/**
|
|
@@ -17,8 +9,6 @@ export interface PluginOptions {
|
|
|
17
9
|
}
|
|
18
10
|
/**
|
|
19
11
|
*
|
|
20
|
-
*
|
|
21
|
-
* @category Options
|
|
22
12
|
*/
|
|
23
13
|
export interface Sidebar {
|
|
24
14
|
autoConfiguration: boolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
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.adjustBaseDirectory = adjustBaseDirectory;
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
/**
|
|
29
|
+
* This method is designed to resolve the base directory paths for documentation presets.
|
|
30
|
+
*/
|
|
31
|
+
function adjustBaseDirectory(originalPath, subPath) {
|
|
32
|
+
// Normalize the paths to handle different path formats and OS differences
|
|
33
|
+
originalPath = path.normalize(originalPath);
|
|
34
|
+
subPath = path.normalize(subPath);
|
|
35
|
+
// Split the original path into an array of segments
|
|
36
|
+
const segments = originalPath.split(path.sep);
|
|
37
|
+
// Split the sub path into an array of segments and filter out ".." to handle relative paths
|
|
38
|
+
const subSegments = subPath
|
|
39
|
+
.split(path.sep)
|
|
40
|
+
.filter((segment) => segment !== '..');
|
|
41
|
+
// Find the index of the first sub path segment in the original path segments
|
|
42
|
+
const startIndex = segments.indexOf(subSegments[0]);
|
|
43
|
+
// Remove the sub path segments from the original path segments if found
|
|
44
|
+
if (startIndex !== -1) {
|
|
45
|
+
segments.splice(startIndex, subSegments.length);
|
|
46
|
+
}
|
|
47
|
+
// Join the segments back into a path and remove the leading slash if present
|
|
48
|
+
let newPath = segments.join(path.sep);
|
|
49
|
+
// Ensure there is no leading slash
|
|
50
|
+
if (newPath.startsWith(path.sep)) {
|
|
51
|
+
newPath = newPath.slice(1);
|
|
52
|
+
}
|
|
53
|
+
return newPath;
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-typedoc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A Docusaurus plugin to integrate TypeDoc ( + typedoc-plugin-markdown ) into a Docusaurus project.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"url": "git+https://github.com/typedoc2md/typedoc-plugin-markdown.git",
|
|
15
15
|
"directory": "packages/docusaurus-plugin-typedoc"
|
|
16
16
|
},
|
|
17
|
-
"homepage": "http://typedoc.org/plugins/docusaurus",
|
|
17
|
+
"homepage": "http://typedoc-plugin-markdown.org/plugins/docusaurus",
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"typedoc-plugin-markdown": ">=4.0.0"
|
|
20
20
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"plugin"
|
|
36
36
|
],
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@docusaurus/core": "^3.
|
|
39
|
-
"@docusaurus/types": "^3.
|
|
38
|
+
"@docusaurus/core": "^3.4.0",
|
|
39
|
+
"@docusaurus/types": "^3.4.0"
|
|
40
40
|
}
|
|
41
41
|
}
|