docusaurus-plugin-typedoc 1.0.5 → 1.1.0
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/index.d.ts +2 -2
- package/dist/index.js +1 -8
- package/dist/models.d.ts +2 -1
- package/dist/models.js +1 -2
- package/dist/options/declarations.d.ts +11 -10
- package/dist/options/declarations.js +18 -9
- package/dist/options/index.d.ts +2 -2
- package/dist/options/index.js +2 -28
- package/dist/{options.d.ts → options/options.d.ts} +1 -1
- package/dist/options/options.js +35 -0
- package/dist/options/presets.d.ts +1 -1
- package/dist/options/presets.js +2 -5
- package/dist/{plugin.d.ts → plugins/docusaurus.d.ts} +1 -1
- package/dist/plugins/docusaurus.js +45 -0
- package/dist/plugins/typedoc.d.ts +2 -0
- package/dist/plugins/typedoc.js +56 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -17
- package/dist/types/options.d.ts +4 -0
- package/dist/types/options.js +1 -2
- package/dist/utils/adjust-basedir.js +2 -28
- package/dist/{sidebar.js → utils/get-sidebar.js} +2 -5
- package/package.json +10 -6
- package/dist/options.js +0 -30
- package/dist/plugin.js +0 -116
- /package/dist/{sidebar.d.ts → utils/get-sidebar.d.ts} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { PluginOptions } from './models';
|
|
2
|
-
export { default } from './
|
|
1
|
+
export { PluginOptions } from './models.js';
|
|
2
|
+
export { default } from './plugins/docusaurus.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var plugin_1 = require("./plugin");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(plugin_1).default; } });
|
|
1
|
+
export { default } from './plugins/docusaurus.js';
|
package/dist/models.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PluginOptions as TypedocPluginMarkdownOptions } from 'typedoc-plugin-markdown';
|
|
2
|
-
import { PluginOptions as DocusaurusOptions } from './types';
|
|
2
|
+
import { PluginOptions as DocusaurusOptions } from './types/index.js';
|
|
3
3
|
export interface PluginOptions extends TypedocPluginMarkdownOptions, DocusaurusOptions {
|
|
4
4
|
id: string;
|
|
5
|
+
out: string;
|
|
5
6
|
}
|
package/dist/models.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeclarationOption } from 'typedoc';
|
|
2
|
+
/**
|
|
3
|
+
* Used internally to pass options from docusaurus.config to TypeDoc.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
export declare const docusaurusConfigOptions: Partial<DeclarationOption>;
|
|
2
10
|
/**
|
|
3
11
|
* **sidebar.autoConfiguration**
|
|
4
12
|
*
|
|
@@ -8,14 +16,7 @@ import { ParameterType } from 'typedoc';
|
|
|
8
16
|
*
|
|
9
17
|
* Pretty format the sidebar JSON.
|
|
10
18
|
*
|
|
11
|
-
* Please see the [sidebar guide](/plugins/docusaurus/
|
|
19
|
+
* Please see the [sidebar guide](https:/typedoc-plugin-markdown.org/plugins/docusaurus/sidebar) for additional information on sidebar setup.
|
|
12
20
|
*
|
|
13
21
|
*/
|
|
14
|
-
export declare const sidebar:
|
|
15
|
-
help: string;
|
|
16
|
-
type: ParameterType;
|
|
17
|
-
defaultValue: {
|
|
18
|
-
autoConfiguration: boolean;
|
|
19
|
-
pretty: boolean;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
+
export declare const sidebar: Partial<DeclarationOption>;
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ParameterType } from 'typedoc';
|
|
2
|
+
import { DEFAULT_SIDEBAR_OPTIONS } from './options.js';
|
|
3
|
+
/**
|
|
4
|
+
* Used internally to pass options from docusaurus.config to TypeDoc.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*
|
|
8
|
+
* @hidden
|
|
9
|
+
*/
|
|
10
|
+
export const docusaurusConfigOptions = {
|
|
11
|
+
help: 'docusaurus.config options - should not be used if running as a docusaurus plugin.',
|
|
12
|
+
type: ParameterType.String,
|
|
13
|
+
defaultValue: '{}',
|
|
14
|
+
};
|
|
6
15
|
/**
|
|
7
16
|
* **sidebar.autoConfiguration**
|
|
8
17
|
*
|
|
@@ -12,11 +21,11 @@ const options_1 = require("../options");
|
|
|
12
21
|
*
|
|
13
22
|
* Pretty format the sidebar JSON.
|
|
14
23
|
*
|
|
15
|
-
* Please see the [sidebar guide](/plugins/docusaurus/
|
|
24
|
+
* Please see the [sidebar guide](https:/typedoc-plugin-markdown.org/plugins/docusaurus/sidebar) for additional information on sidebar setup.
|
|
16
25
|
*
|
|
17
26
|
*/
|
|
18
|
-
|
|
27
|
+
export const sidebar = {
|
|
19
28
|
help: 'Configures the autogenerated Docusaurus sidebar.',
|
|
20
|
-
type:
|
|
21
|
-
defaultValue:
|
|
29
|
+
type: ParameterType.Mixed,
|
|
30
|
+
defaultValue: DEFAULT_SIDEBAR_OPTIONS,
|
|
22
31
|
};
|
package/dist/options/index.d.ts
CHANGED
package/dist/options/index.js
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* All plugin types are exported from this module.
|
|
4
3
|
*
|
|
5
4
|
* @module
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
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"));
|
|
6
|
+
export * as declarations from './declarations.js';
|
|
7
|
+
export * as presets from './presets.js';
|
|
@@ -2,4 +2,4 @@ export declare const DEFAULT_SIDEBAR_OPTIONS: {
|
|
|
2
2
|
autoConfiguration: boolean;
|
|
3
3
|
pretty: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare function getPluginOptions(opts: Record<string, any>): Record<string, any>;
|
|
5
|
+
export declare function getPluginOptions(context: any, opts: Record<string, any>): Record<string, any>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { presets } from './presets.js';
|
|
2
|
+
export const DEFAULT_SIDEBAR_OPTIONS = {
|
|
3
|
+
autoConfiguration: true,
|
|
4
|
+
pretty: false,
|
|
5
|
+
};
|
|
6
|
+
const DEFAULT_PLUGIN_OPTIONS = {
|
|
7
|
+
...presets,
|
|
8
|
+
id: 'default',
|
|
9
|
+
sidebar: {
|
|
10
|
+
...DEFAULT_SIDEBAR_OPTIONS,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export function getPluginOptions(context, opts) {
|
|
14
|
+
const docsPreset = context.siteConfig?.presets?.find((preset) => Boolean(preset[1]?.docs));
|
|
15
|
+
const options = {
|
|
16
|
+
...DEFAULT_PLUGIN_OPTIONS,
|
|
17
|
+
siteDir: context.siteDir,
|
|
18
|
+
docsPresetPath: docsPreset ? docsPreset[1]?.docs?.path : null,
|
|
19
|
+
numberPrefixParser: docsPreset
|
|
20
|
+
? docsPreset[1]?.docs?.numberPrefixParser
|
|
21
|
+
: null,
|
|
22
|
+
...opts,
|
|
23
|
+
sidebar: {
|
|
24
|
+
...DEFAULT_PLUGIN_OPTIONS.sidebar,
|
|
25
|
+
...opts.sidebar,
|
|
26
|
+
},
|
|
27
|
+
plugin: [
|
|
28
|
+
...new Set([
|
|
29
|
+
...['typedoc-plugin-markdown', 'docusaurus-plugin-typedoc'],
|
|
30
|
+
...(opts.plugin || []),
|
|
31
|
+
]),
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
return options;
|
|
35
|
+
}
|
package/dist/options/presets.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.presets = void 0;
|
|
4
|
-
exports.presets = {
|
|
1
|
+
export const presets = {
|
|
2
|
+
plugin: ['typedoc-plugin-markdown', 'docusaurus-plugin-typedoc'],
|
|
5
3
|
out: './docs/api',
|
|
6
4
|
hideBreadcrumbs: true,
|
|
7
5
|
hidePageHeader: true,
|
|
8
6
|
entryFileName: 'index.md',
|
|
9
|
-
plugin: ['typedoc-plugin-markdown'],
|
|
10
7
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
import { getPluginOptions } from '../options/options.js';
|
|
5
|
+
import { presets } from '../options/presets.js';
|
|
6
|
+
export default async function pluginDocusaurus(context, opts) {
|
|
7
|
+
await generateTypedoc(context, opts);
|
|
8
|
+
return {
|
|
9
|
+
name: 'docusaurus-plugin-typedoc',
|
|
10
|
+
extendCli(cli) {
|
|
11
|
+
cli
|
|
12
|
+
.command('generate-typedoc')
|
|
13
|
+
.description(`[docusaurus-plugin-typedoc] Generate TypeDoc docs independently of the Docusaurus build process.`)
|
|
14
|
+
.action(async () => {
|
|
15
|
+
context.siteConfig?.plugins.forEach((pluginConfig) => {
|
|
16
|
+
// Check PluginConfig is typed to [string, PluginOptions]
|
|
17
|
+
if (pluginConfig && typeof pluginConfig[1] === 'object') {
|
|
18
|
+
generateTypedoc(context, pluginConfig[1]);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Initiates a new typedoc Application bootstrapped with plugin options
|
|
27
|
+
*/
|
|
28
|
+
async function generateTypedoc(context, opts) {
|
|
29
|
+
// create outDir if it doesn't exist
|
|
30
|
+
const outputDir = path.join(context?.siteDir, presets.out);
|
|
31
|
+
if (!fs.existsSync(outputDir)) {
|
|
32
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
// spawn typedoc process and pass docusaurus.config options as a string
|
|
35
|
+
spawnSync('typedoc', [
|
|
36
|
+
'--docusaurusConfigOptions',
|
|
37
|
+
`${JSON.stringify(getPluginOptions(context, opts))}`,
|
|
38
|
+
'--plugin',
|
|
39
|
+
'typedoc-plugin-markdown',
|
|
40
|
+
'--plugin',
|
|
41
|
+
'docusaurus-plugin-typedoc/typedoc',
|
|
42
|
+
], {
|
|
43
|
+
stdio: 'inherit',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as options from '../options/declarations.js';
|
|
4
|
+
import { adjustBaseDirectory } from '../utils/adjust-basedir.js';
|
|
5
|
+
import { getSidebar } from '../utils/get-sidebar.js';
|
|
6
|
+
export function load(app) {
|
|
7
|
+
Object.entries(options).forEach(([name, option]) => {
|
|
8
|
+
app.options.addDeclaration({
|
|
9
|
+
name,
|
|
10
|
+
...option,
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
app.options.addReader(new (class {
|
|
14
|
+
name = 'docusaurus-options';
|
|
15
|
+
order = 100;
|
|
16
|
+
supportsPackages = false;
|
|
17
|
+
read(container) {
|
|
18
|
+
const presets = JSON.parse(container.getValue('docusaurusConfigOptions'));
|
|
19
|
+
const ignoreKeys = [
|
|
20
|
+
'id',
|
|
21
|
+
'siteDir',
|
|
22
|
+
'docsPresetPath',
|
|
23
|
+
'numberPrefixParser',
|
|
24
|
+
];
|
|
25
|
+
Object.entries(presets)
|
|
26
|
+
.filter(([key]) => !ignoreKeys.includes(key))
|
|
27
|
+
.forEach(([key, value]) => {
|
|
28
|
+
container.setValue(key, value);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
})());
|
|
32
|
+
app.renderer.postRenderAsyncJobs.push(async (output) => {
|
|
33
|
+
const outputDir = app.options.getValue('out');
|
|
34
|
+
const docusaurusConfigOptions = JSON.parse(app.options.getValue('docusaurusConfigOptions'));
|
|
35
|
+
const sidebar = app.options.getValue('sidebar');
|
|
36
|
+
const siteDir = docusaurusConfigOptions.siteDir;
|
|
37
|
+
const docsPresetPath = docusaurusConfigOptions.docsPresetPath;
|
|
38
|
+
const numberPrefixParser = docusaurusConfigOptions.numberPrefixParser;
|
|
39
|
+
if (sidebar?.autoConfiguration && output.navigation) {
|
|
40
|
+
const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
|
|
41
|
+
let baseDir = path
|
|
42
|
+
.relative(siteDir, outputDir)
|
|
43
|
+
.split(path.sep)
|
|
44
|
+
.slice(1)
|
|
45
|
+
.join('/');
|
|
46
|
+
if (docsPresetPath) {
|
|
47
|
+
baseDir = adjustBaseDirectory(baseDir, docsPresetPath);
|
|
48
|
+
}
|
|
49
|
+
const sidebarJson = getSidebar(output.navigation, baseDir, numberPrefixParser);
|
|
50
|
+
fs.writeFileSync(sidebarPath, `// @ts-check
|
|
51
|
+
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
|
52
|
+
const typedocSidebar = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
|
|
53
|
+
module.exports = typedocSidebar.items;`);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* All plugin types are exported from this module.
|
|
4
3
|
*
|
|
5
4
|
* @module
|
|
6
5
|
*/
|
|
7
|
-
|
|
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);
|
|
6
|
+
export * from './options.js';
|
package/dist/types/options.d.ts
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* Describes the options declared by the plugin.
|
|
3
3
|
*/
|
|
4
4
|
export interface PluginOptions {
|
|
5
|
+
/**
|
|
6
|
+
* docusaurus.config options - should not be used if running as a docusaurus plugin.
|
|
7
|
+
*/
|
|
8
|
+
docusaurusConfigOptions: string;
|
|
5
9
|
/**
|
|
6
10
|
* Configures the autogenerated Docusaurus sidebar.
|
|
7
11
|
*/
|
package/dist/types/options.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,34 +1,8 @@
|
|
|
1
|
-
|
|
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"));
|
|
1
|
+
import * as path from 'path';
|
|
28
2
|
/**
|
|
29
3
|
* This method is designed to resolve the base directory paths for documentation presets.
|
|
30
4
|
*/
|
|
31
|
-
function adjustBaseDirectory(originalPath, subPath) {
|
|
5
|
+
export function adjustBaseDirectory(originalPath, subPath) {
|
|
32
6
|
// Normalize the paths to handle different path formats and OS differences
|
|
33
7
|
originalPath = path.normalize(originalPath);
|
|
34
8
|
subPath = path.normalize(subPath);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSidebar = getSidebar;
|
|
4
|
-
function getSidebar(navigation, basePath, numberPrefixParser) {
|
|
1
|
+
export function getSidebar(navigation, basePath, numberPrefixParser) {
|
|
5
2
|
return navigation
|
|
6
3
|
.map((navigationItem) => getNavigationItem(navigationItem, basePath, numberPrefixParser))
|
|
7
4
|
.filter((navItem) => Boolean(navItem));
|
|
@@ -10,7 +7,7 @@ function getNavigationItem(navigationItem, basePath, numberPrefixParser) {
|
|
|
10
7
|
const navigationItemPath = navigationItem.path || navigationItem.url;
|
|
11
8
|
const parsedUrl = numberPrefixParser === false
|
|
12
9
|
? navigationItemPath
|
|
13
|
-
: navigationItemPath?.replace(/\d
|
|
10
|
+
: navigationItemPath?.replace(/\d+-/g, '');
|
|
14
11
|
const getId = () => {
|
|
15
12
|
const idParts = [];
|
|
16
13
|
if (basePath.length > 0) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-typedoc",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A Docusaurus plugin to integrate TypeDoc ( + typedoc-plugin-markdown ) into a Docusaurus project.",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./dist/index.js",
|
|
7
|
+
"./typedoc": "./dist/plugins/typedoc.js"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
6
10
|
"files": [
|
|
7
11
|
"dist/"
|
|
8
12
|
],
|
|
@@ -16,10 +20,10 @@
|
|
|
16
20
|
},
|
|
17
21
|
"homepage": "http://typedoc-plugin-markdown.org/plugins/docusaurus",
|
|
18
22
|
"peerDependencies": {
|
|
19
|
-
"typedoc-plugin-markdown": ">=4.
|
|
23
|
+
"typedoc-plugin-markdown": ">=4.3.0"
|
|
20
24
|
},
|
|
21
25
|
"scripts": {
|
|
22
|
-
"lint": "eslint ./src
|
|
26
|
+
"lint": "eslint ./src",
|
|
23
27
|
"prebuild": "rm -rf dist && prebuild-options",
|
|
24
28
|
"prepublishOnly": "npm run lint && npm run build",
|
|
25
29
|
"build": "tsc",
|
|
@@ -35,7 +39,7 @@
|
|
|
35
39
|
"plugin"
|
|
36
40
|
],
|
|
37
41
|
"devDependencies": {
|
|
38
|
-
"@docusaurus/core": "^3.
|
|
39
|
-
"@docusaurus/types": "^3.
|
|
42
|
+
"@docusaurus/core": "^3.6.1",
|
|
43
|
+
"@docusaurus/types": "^3.6.1"
|
|
40
44
|
}
|
|
41
45
|
}
|
package/dist/options.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_SIDEBAR_OPTIONS = void 0;
|
|
4
|
-
exports.getPluginOptions = getPluginOptions;
|
|
5
|
-
const presets_1 = require("./options/presets");
|
|
6
|
-
exports.DEFAULT_SIDEBAR_OPTIONS = {
|
|
7
|
-
autoConfiguration: true,
|
|
8
|
-
pretty: false,
|
|
9
|
-
};
|
|
10
|
-
const DEFAULT_PLUGIN_OPTIONS = {
|
|
11
|
-
...presets_1.presets,
|
|
12
|
-
id: 'default',
|
|
13
|
-
sidebar: {
|
|
14
|
-
...exports.DEFAULT_SIDEBAR_OPTIONS,
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
function getPluginOptions(opts) {
|
|
18
|
-
const options = {
|
|
19
|
-
...DEFAULT_PLUGIN_OPTIONS,
|
|
20
|
-
...opts,
|
|
21
|
-
sidebar: {
|
|
22
|
-
...DEFAULT_PLUGIN_OPTIONS.sidebar,
|
|
23
|
-
...opts.sidebar,
|
|
24
|
-
},
|
|
25
|
-
plugin: [
|
|
26
|
-
...new Set([...DEFAULT_PLUGIN_OPTIONS.plugin, ...(opts.plugin || [])]),
|
|
27
|
-
],
|
|
28
|
-
};
|
|
29
|
-
return options;
|
|
30
|
-
}
|
package/dist/plugin.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
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.default = pluginDocusaurus;
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
const path = __importStar(require("path"));
|
|
29
|
-
const typedoc_1 = require("typedoc");
|
|
30
|
-
const options_1 = require("./options");
|
|
31
|
-
const options = __importStar(require("./options/declarations"));
|
|
32
|
-
const sidebar_1 = require("./sidebar");
|
|
33
|
-
const adjust_basedir_1 = require("./utils/adjust-basedir");
|
|
34
|
-
// store list of plugin ids when running multiple instances
|
|
35
|
-
const apps = [];
|
|
36
|
-
async function pluginDocusaurus(context, opts) {
|
|
37
|
-
const PLUGIN_NAME = 'docusaurus-plugin-typedoc';
|
|
38
|
-
if (opts.id && !apps.includes(opts.id)) {
|
|
39
|
-
apps.push(opts.id);
|
|
40
|
-
await generateTypedoc(context, opts);
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
name: PLUGIN_NAME,
|
|
44
|
-
extendCli(cli) {
|
|
45
|
-
cli
|
|
46
|
-
.command('generate-typedoc')
|
|
47
|
-
.description(`[${PLUGIN_NAME}] Generate TypeDoc docs independently of the Docusaurus build process.`)
|
|
48
|
-
.action(async () => {
|
|
49
|
-
context.siteConfig?.plugins.forEach((pluginConfig) => {
|
|
50
|
-
// Check PluginConfig is typed to [string, PluginOptions]
|
|
51
|
-
if (pluginConfig && typeof pluginConfig[1] === 'object') {
|
|
52
|
-
generateTypedoc(context, pluginConfig[1]);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Initiates a new typedoc Application bootstrapped with plugin options
|
|
61
|
-
*/
|
|
62
|
-
async function generateTypedoc(context, opts) {
|
|
63
|
-
const { siteDir } = context;
|
|
64
|
-
const pluginOptions = (0, options_1.getPluginOptions)(opts);
|
|
65
|
-
const { id, sidebar, ...optionsPassedToTypeDoc } = pluginOptions;
|
|
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));
|
|
71
|
-
Object.entries(options).forEach(([name, option]) => {
|
|
72
|
-
app.options.addDeclaration({
|
|
73
|
-
name,
|
|
74
|
-
...option,
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
if (sidebar?.autoConfiguration) {
|
|
78
|
-
const docsPreset = context.siteConfig?.presets?.find((preset) => Boolean(preset[1]?.docs));
|
|
79
|
-
app.renderer.postRenderAsyncJobs.push(async (output) => {
|
|
80
|
-
if (output.navigation) {
|
|
81
|
-
const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
|
|
82
|
-
let baseDir = path
|
|
83
|
-
.relative(siteDir, outputDir)
|
|
84
|
-
.split(path.sep)
|
|
85
|
-
.slice(1)
|
|
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
|
-
}
|
|
91
|
-
const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, baseDir, docsPreset ? docsPreset[1]?.docs?.numberPrefixParser : null);
|
|
92
|
-
fs.writeFileSync(sidebarPath, `// @ts-check
|
|
93
|
-
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
|
94
|
-
const typedocSidebar = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
|
|
95
|
-
module.exports = typedocSidebar.items;`);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
const project = await app.convert();
|
|
100
|
-
// if project is undefined typedoc has a problem - error logging will be supplied by typedoc.
|
|
101
|
-
if (!project) {
|
|
102
|
-
if (app.options.getValue('skipErrorChecking')) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
console.error('[docusaurus-plugin-typedoc] TypeDoc exited with an error. Use the "skipErrorChecking" option to disable TypeDoc error checking.');
|
|
106
|
-
process.exit(1);
|
|
107
|
-
}
|
|
108
|
-
if (app.options.getValue('watch')) {
|
|
109
|
-
app.convertAndWatch(async (project) => {
|
|
110
|
-
await app.generateDocs(project, outputDir);
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
await app.generateDocs(project, outputDir);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
File without changes
|