docusaurus-plugin-typedoc 1.0.2 → 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/dist/plugin.js
CHANGED
|
@@ -30,6 +30,7 @@ const typedoc_1 = require("typedoc");
|
|
|
30
30
|
const options_1 = require("./options");
|
|
31
31
|
const options = __importStar(require("./options/declarations"));
|
|
32
32
|
const sidebar_1 = require("./sidebar");
|
|
33
|
+
const adjust_basedir_1 = require("./utils/adjust-basedir");
|
|
33
34
|
// store list of plugin ids when running multiple instances
|
|
34
35
|
const apps = [];
|
|
35
36
|
async function pluginDocusaurus(context, opts) {
|
|
@@ -78,11 +79,15 @@ async function generateTypedoc(context, opts) {
|
|
|
78
79
|
app.renderer.postRenderAsyncJobs.push(async (output) => {
|
|
79
80
|
if (output.navigation) {
|
|
80
81
|
const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
|
|
81
|
-
|
|
82
|
+
let baseDir = path
|
|
82
83
|
.relative(siteDir, outputDir)
|
|
83
84
|
.split(path.sep)
|
|
84
85
|
.slice(1)
|
|
85
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
|
+
}
|
|
86
91
|
const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, baseDir, docsPreset ? docsPreset[1]?.docs?.numberPrefixParser : null);
|
|
87
92
|
fs.writeFileSync(sidebarPath, `// @ts-check
|
|
88
93
|
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
|
@@ -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