docusaurus-plugin-typedoc 1.0.0-next.27 → 1.0.0-next.29
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 +2 -6
- package/dist/models.d.ts +2 -7
- package/dist/options/declarations.d.ts +36 -0
- package/dist/options/declarations.js +37 -0
- package/dist/options/option-types.d.ts +26 -0
- package/dist/options/option-types.js +3 -0
- package/dist/options/presets.d.ts +8 -0
- package/dist/options/presets.js +9 -0
- package/dist/options.d.ts +4 -2
- package/dist/options.js +11 -16
- package/dist/plugin.js +22 -18
- package/dist/sidebar.d.ts +1 -1
- package/dist/sidebar.js +17 -12
- package/package.json +6 -5
- package/LICENSE +0 -21
- package/dist/theme.d.ts +0 -5
- package/dist/theme.js +0 -27
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# docusaurus-plugin-typedoc
|
|
2
2
|
|
|
3
|
-

|
|
3
|
+
 [](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml)
|
|
4
4
|
|
|
5
5
|
A Docusaurus plugin to integrate TypeDoc into a Docusaurus project.
|
|
6
6
|
|
|
@@ -12,8 +12,4 @@ A Docusaurus plugin to integrate TypeDoc into a Docusaurus project.
|
|
|
12
12
|
|
|
13
13
|
## Documentation
|
|
14
14
|
|
|
15
|
-
Please visit https://typedoc-plugin-markdown.org/
|
|
16
|
-
|
|
17
|
-
## License
|
|
18
|
-
|
|
19
|
-
Released under the [MIT License](./LICENSE).
|
|
15
|
+
Please visit [typedoc-plugin-markdown.org](https://typedoc-plugin-markdown.org/plugins/docusaurus) for comprehensive documentation, including options and usage guides.
|
package/dist/models.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { PluginOptions as TypedocPluginMarkdownOptions } from 'typedoc-plugin-markdown';
|
|
2
|
-
|
|
2
|
+
import { PluginOptions as DocusaurusOptions } from './options/option-types';
|
|
3
|
+
export interface PluginOptions extends TypedocPluginMarkdownOptions, DocusaurusOptions {
|
|
3
4
|
id: string;
|
|
4
|
-
sidebar: Partial<SidebarOptions>;
|
|
5
|
-
}
|
|
6
|
-
export interface SidebarOptions {
|
|
7
|
-
autoConfiguration: boolean;
|
|
8
|
-
pretty: boolean;
|
|
9
|
-
filteredIds: string[];
|
|
10
5
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ParameterType } from 'typedoc';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* > *In addition to the sidebar options listed below, you can configure the structure of the sidebar by utilizing the TypeDoc [`navigation options`](https://typedoc.org/options/output/#navigation) `includeGroups`, `includeCategories` and `includeFolders`*.
|
|
5
|
+
*
|
|
6
|
+
* **sidebar.autoConfiguration**
|
|
7
|
+
*
|
|
8
|
+
* Set to `false` to disable sidebar generation. Defaults to `true`.
|
|
9
|
+
*
|
|
10
|
+
* **sidebar.pretty**
|
|
11
|
+
*
|
|
12
|
+
* Pretty format the sidebar JSON.
|
|
13
|
+
*
|
|
14
|
+
* Please see the [sidebar guide](/plugins/docusaurus/guide/sidebar) for additional information on sidebar setup.
|
|
15
|
+
*
|
|
16
|
+
* ```json filename="Example"
|
|
17
|
+
* "navigation": {
|
|
18
|
+
* "includeGroups": true,
|
|
19
|
+
* "includeCategories": true
|
|
20
|
+
* },
|
|
21
|
+
* "sidebar": {
|
|
22
|
+
* "pretty": true
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @omitExample
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
export declare const sidebar: {
|
|
30
|
+
help: string;
|
|
31
|
+
type: ParameterType;
|
|
32
|
+
defaultValue: {
|
|
33
|
+
autoConfiguration: boolean;
|
|
34
|
+
pretty: boolean;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sidebar = void 0;
|
|
4
|
+
const typedoc_1 = require("typedoc");
|
|
5
|
+
const options_1 = require("../options");
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* > *In addition to the sidebar options listed below, you can configure the structure of the sidebar by utilizing the TypeDoc [`navigation options`](https://typedoc.org/options/output/#navigation) `includeGroups`, `includeCategories` and `includeFolders`*.
|
|
9
|
+
*
|
|
10
|
+
* **sidebar.autoConfiguration**
|
|
11
|
+
*
|
|
12
|
+
* Set to `false` to disable sidebar generation. Defaults to `true`.
|
|
13
|
+
*
|
|
14
|
+
* **sidebar.pretty**
|
|
15
|
+
*
|
|
16
|
+
* Pretty format the sidebar JSON.
|
|
17
|
+
*
|
|
18
|
+
* Please see the [sidebar guide](/plugins/docusaurus/guide/sidebar) for additional information on sidebar setup.
|
|
19
|
+
*
|
|
20
|
+
* ```json filename="Example"
|
|
21
|
+
* "navigation": {
|
|
22
|
+
* "includeGroups": true,
|
|
23
|
+
* "includeCategories": true
|
|
24
|
+
* },
|
|
25
|
+
* "sidebar": {
|
|
26
|
+
* "pretty": true
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @omitExample
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
exports.sidebar = {
|
|
34
|
+
help: 'Configures the autogenerated Docusaurus sidebar.',
|
|
35
|
+
type: typedoc_1.ParameterType.Mixed,
|
|
36
|
+
defaultValue: options_1.DEFAULT_SIDEBAR_OPTIONS,
|
|
37
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ManuallyValidatedOption } from 'typedoc';
|
|
2
|
+
declare module 'typedoc' {
|
|
3
|
+
interface TypeDocOptionMap {
|
|
4
|
+
sidebar: ManuallyValidatedOption<Sidebar>;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Describes the options declared by the plugin.
|
|
9
|
+
*
|
|
10
|
+
* @category Options
|
|
11
|
+
*/
|
|
12
|
+
export interface PluginOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Configures the autogenerated Docusaurus sidebar.
|
|
15
|
+
*/
|
|
16
|
+
sidebar: Sidebar;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
*
|
|
21
|
+
* @category Options
|
|
22
|
+
*/
|
|
23
|
+
export interface Sidebar {
|
|
24
|
+
autoConfiguration: boolean;
|
|
25
|
+
pretty: boolean;
|
|
26
|
+
}
|
package/dist/options.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export declare const DEFAULT_SIDEBAR_OPTIONS: {
|
|
2
|
+
autoConfiguration: boolean;
|
|
3
|
+
pretty: boolean;
|
|
4
|
+
};
|
|
2
5
|
export declare function getPluginOptions(opts: Record<string, any>): Record<string, any>;
|
|
3
|
-
export declare function setOptions(app: Application, options: any): void;
|
package/dist/options.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
6
|
+
exports.getPluginOptions = exports.DEFAULT_SIDEBAR_OPTIONS = void 0;
|
|
7
|
+
const presets_1 = __importDefault(require("./options/presets"));
|
|
8
|
+
exports.DEFAULT_SIDEBAR_OPTIONS = {
|
|
9
|
+
autoConfiguration: true,
|
|
10
|
+
pretty: false,
|
|
11
|
+
};
|
|
4
12
|
const DEFAULT_PLUGIN_OPTIONS = {
|
|
13
|
+
...presets_1.default,
|
|
5
14
|
id: 'default',
|
|
6
|
-
out: './docs/api',
|
|
7
|
-
hideBreadcrumbs: true,
|
|
8
|
-
hidePageHeader: true,
|
|
9
|
-
entryFileName: 'index.md',
|
|
10
|
-
theme: 'docusaurus',
|
|
11
15
|
sidebar: {
|
|
12
|
-
|
|
13
|
-
pretty: false,
|
|
14
|
-
filteredIds: [],
|
|
16
|
+
...exports.DEFAULT_SIDEBAR_OPTIONS,
|
|
15
17
|
},
|
|
16
|
-
plugin: ['typedoc-plugin-markdown'],
|
|
17
18
|
};
|
|
18
19
|
function getPluginOptions(opts) {
|
|
19
20
|
const options = {
|
|
@@ -30,9 +31,3 @@ function getPluginOptions(opts) {
|
|
|
30
31
|
return options;
|
|
31
32
|
}
|
|
32
33
|
exports.getPluginOptions = getPluginOptions;
|
|
33
|
-
function setOptions(app, options) {
|
|
34
|
-
for (const [key, val] of Object.entries(options)) {
|
|
35
|
-
app.options.setValue(key, val);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.setOptions = setOptions;
|
package/dist/plugin.js
CHANGED
|
@@ -27,8 +27,8 @@ const fs = __importStar(require("fs"));
|
|
|
27
27
|
const path = __importStar(require("path"));
|
|
28
28
|
const typedoc_1 = require("typedoc");
|
|
29
29
|
const options_1 = require("./options");
|
|
30
|
+
const options = __importStar(require("./options/declarations"));
|
|
30
31
|
const sidebar_1 = require("./sidebar");
|
|
31
|
-
const theme_1 = require("./theme");
|
|
32
32
|
// store list of plugin ids when running multiple instances
|
|
33
33
|
const apps = [];
|
|
34
34
|
async function pluginDocusaurus(context, opts) {
|
|
@@ -60,30 +60,34 @@ exports.default = pluginDocusaurus;
|
|
|
60
60
|
*/
|
|
61
61
|
async function generateTypedoc(context, opts) {
|
|
62
62
|
const { siteDir } = context;
|
|
63
|
-
const
|
|
64
|
-
const { id, sidebar, ...optionsPassedToTypeDoc } =
|
|
63
|
+
const pluginOpions = (0, options_1.getPluginOptions)(opts);
|
|
64
|
+
const { id, sidebar, ...optionsPassedToTypeDoc } = pluginOpions;
|
|
65
65
|
const app = await typedoc_1.Application.bootstrapWithPlugins(optionsPassedToTypeDoc);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
event.contents = event.contents?.replace(/\\</g, '<');
|
|
66
|
+
Object.entries(options).forEach(([name, option]) => {
|
|
67
|
+
app.options.addDeclaration({
|
|
68
|
+
name,
|
|
69
|
+
...option,
|
|
71
70
|
});
|
|
72
|
-
}
|
|
71
|
+
});
|
|
72
|
+
const outputDir = app.options.getValue('out');
|
|
73
73
|
if (sidebar?.autoConfiguration) {
|
|
74
74
|
const docsPreset = context.siteConfig?.presets?.find((preset) => Boolean(preset[1]?.docs));
|
|
75
75
|
app.renderer.postRenderAsyncJobs.push(async (output) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.
|
|
79
|
-
.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
if (output.navigation) {
|
|
77
|
+
const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
|
|
78
|
+
const sidebarJSONPath = path.resolve(outputDir, 'typedoc-sidebar.json');
|
|
79
|
+
fs.writeFileSync(sidebarJSONPath, JSON.stringify(output.navigation, null, 2));
|
|
80
|
+
const baseDir = path
|
|
81
|
+
.relative(siteDir, outputDir)
|
|
82
|
+
.split(path.sep)
|
|
83
|
+
.slice(1)
|
|
84
|
+
.join(path.sep);
|
|
85
|
+
const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, baseDir, docsPreset ? docsPreset[1]?.docs?.numberPrefixParser : null);
|
|
86
|
+
fs.writeFileSync(sidebarPath, `// @ts-check
|
|
84
87
|
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
|
85
88
|
const typedocSidebar = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
|
|
86
89
|
module.exports = typedocSidebar.items;`);
|
|
90
|
+
}
|
|
87
91
|
});
|
|
88
92
|
}
|
|
89
93
|
const project = await app.convert();
|
|
@@ -93,7 +97,7 @@ module.exports = typedocSidebar.items;`);
|
|
|
93
97
|
return;
|
|
94
98
|
}
|
|
95
99
|
console.error('[docusaurus-plugin-typedoc] TypeDoc exited with an error. Use the "skipErrorChecking" option to disable TypeDoc error checking.');
|
|
96
|
-
process.exit();
|
|
100
|
+
process.exit(1);
|
|
97
101
|
}
|
|
98
102
|
if (app.options.getValue('watch')) {
|
|
99
103
|
app.convertAndWatch(async (project) => {
|
package/dist/sidebar.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { NavigationItem } from 'typedoc-plugin-markdown';
|
|
2
|
-
export declare function getSidebar(navigation: NavigationItem[], basePath: string,
|
|
2
|
+
export declare function getSidebar(navigation: NavigationItem[], basePath: string, numberPrefixParser?: any): any;
|
package/dist/sidebar.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSidebar = void 0;
|
|
4
|
-
function getSidebar(navigation, basePath,
|
|
4
|
+
function getSidebar(navigation, basePath, numberPrefixParser) {
|
|
5
5
|
return navigation
|
|
6
|
-
.map((navigationItem) => getNavigationItem(navigationItem, basePath,
|
|
6
|
+
.map((navigationItem) => getNavigationItem(navigationItem, basePath, numberPrefixParser))
|
|
7
7
|
.filter((navItem) => Boolean(navItem));
|
|
8
8
|
}
|
|
9
9
|
exports.getSidebar = getSidebar;
|
|
10
|
-
function getNavigationItem(navigationItem, basePath,
|
|
10
|
+
function getNavigationItem(navigationItem, basePath, numberPrefixParser) {
|
|
11
11
|
const parsedUrl = numberPrefixParser === false
|
|
12
|
-
? navigationItem.
|
|
13
|
-
: navigationItem.
|
|
12
|
+
? navigationItem.path
|
|
13
|
+
: navigationItem.path?.replace(/\d+\-/g, '');
|
|
14
14
|
const getId = () => {
|
|
15
15
|
const idParts = [];
|
|
16
16
|
if (basePath.length > 0) {
|
|
@@ -19,8 +19,8 @@ function getNavigationItem(navigationItem, basePath, filteredIds, numberPrefixPa
|
|
|
19
19
|
if (parsedUrl) {
|
|
20
20
|
idParts.push(parsedUrl);
|
|
21
21
|
}
|
|
22
|
-
if (navigationItem.
|
|
23
|
-
return idParts.join('/').replace(/(.*)
|
|
22
|
+
if (navigationItem.path) {
|
|
23
|
+
return idParts.join('/').replace(/(.*)\.\w+$/, '$1');
|
|
24
24
|
}
|
|
25
25
|
return null;
|
|
26
26
|
};
|
|
@@ -28,16 +28,21 @@ function getNavigationItem(navigationItem, basePath, filteredIds, numberPrefixPa
|
|
|
28
28
|
if (navigationItem.children?.length) {
|
|
29
29
|
return {
|
|
30
30
|
type: 'category',
|
|
31
|
-
label: navigationItem.title
|
|
32
|
-
items: getSidebar(navigationItem.children, basePath,
|
|
33
|
-
...(id && {
|
|
31
|
+
label: `${navigationItem.title}`,
|
|
32
|
+
items: getSidebar(navigationItem.children, basePath, numberPrefixParser),
|
|
33
|
+
...(id && {
|
|
34
|
+
link: {
|
|
35
|
+
type: 'doc',
|
|
36
|
+
id,
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
34
39
|
};
|
|
35
40
|
}
|
|
36
|
-
return id
|
|
41
|
+
return id
|
|
37
42
|
? {
|
|
38
43
|
type: 'doc',
|
|
39
44
|
id,
|
|
40
|
-
label: navigationItem.title
|
|
45
|
+
label: `${navigationItem.title}`,
|
|
41
46
|
}
|
|
42
47
|
: null;
|
|
43
48
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-typedoc",
|
|
3
|
-
"version": "1.0.0-next.
|
|
4
|
-
"description": "A Docusaurus plugin to integrate TypeDoc into a Docusaurus project.",
|
|
3
|
+
"version": "1.0.0-next.29",
|
|
4
|
+
"description": "A Docusaurus plugin to integrate TypeDoc ( + typedoc-plugin-markdown ) into a Docusaurus project.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist/"
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"lint": "eslint ./src --ext .ts",
|
|
23
|
+
"prebuild": "rm -rf dist && prebuild-options",
|
|
23
24
|
"prepublishOnly": "npm run lint && npm run build",
|
|
24
|
-
"build": "
|
|
25
|
+
"build": "tsc",
|
|
25
26
|
"pretest": "rm -rf ./test/out && docusaurus generate-typedoc",
|
|
26
27
|
"test": "jest",
|
|
27
28
|
"test:update": "npm run build && npm test -- -u"
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"api"
|
|
38
39
|
],
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@docusaurus/core": "^3.
|
|
41
|
-
"@docusaurus/types": "^3.
|
|
41
|
+
"@docusaurus/core": "^3.2.1",
|
|
42
|
+
"@docusaurus/types": "^3.2.1"
|
|
42
43
|
}
|
|
43
44
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 Thomas Grey
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/theme.d.ts
DELETED
package/dist/theme.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DocusuaurusTheme = void 0;
|
|
4
|
-
const typedoc_1 = require("typedoc");
|
|
5
|
-
const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
|
|
6
|
-
class DocusuaurusTheme extends typedoc_plugin_markdown_1.MarkdownTheme {
|
|
7
|
-
getRenderContext(pageEvent) {
|
|
8
|
-
return new DocusuaurusThemeThemeRenderContext(this, pageEvent, this.application.options);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.DocusuaurusTheme = DocusuaurusTheme;
|
|
12
|
-
class DocusuaurusThemeThemeRenderContext extends typedoc_plugin_markdown_1.MarkdownThemeRenderContext {
|
|
13
|
-
constructor() {
|
|
14
|
-
super(...arguments);
|
|
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.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
|
-
},
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|