docusaurus-plugin-typedoc 1.2.0 → 1.2.2
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/options/declarations.d.ts +6 -2
- package/dist/options/declarations.js +15 -2
- package/dist/options/options.d.ts +1 -0
- package/dist/options/options.js +1 -0
- package/dist/plugins/docusaurus.js +2 -1
- package/dist/plugins/typedoc.js +1 -1
- package/dist/types/options.d.ts +1 -0
- package/dist/utils/get-sidebar.d.ts +2 -1
- package/dist/utils/get-sidebar.js +9 -17
- package/package.json +1 -1
|
@@ -8,14 +8,18 @@ import { DeclarationOption } from 'typedoc';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const docusaurusConfigOptions: Partial<DeclarationOption>;
|
|
10
10
|
/**
|
|
11
|
-
* **
|
|
11
|
+
* **autoConfiguration**
|
|
12
12
|
*
|
|
13
13
|
* Set to `false` to disable sidebar generation. Defaults to `true`.
|
|
14
14
|
*
|
|
15
|
-
* **
|
|
15
|
+
* **pretty**
|
|
16
16
|
*
|
|
17
17
|
* Pretty format the sidebar JSON.
|
|
18
18
|
*
|
|
19
|
+
* **deprecatedItemClassName**
|
|
20
|
+
*
|
|
21
|
+
* The class name to apply to deprecated items in the sidebar. Defaults to `"typedoc-sidebar-item-deprecated"`.
|
|
22
|
+
*
|
|
19
23
|
* Please see the [sidebar guide](https:/typedoc-plugin-markdown.org/plugins/docusaurus/sidebar) for additional information on sidebar setup.
|
|
20
24
|
*
|
|
21
25
|
*/
|
|
@@ -13,14 +13,18 @@ export const docusaurusConfigOptions = {
|
|
|
13
13
|
defaultValue: '{}',
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
* **
|
|
16
|
+
* **autoConfiguration**
|
|
17
17
|
*
|
|
18
18
|
* Set to `false` to disable sidebar generation. Defaults to `true`.
|
|
19
19
|
*
|
|
20
|
-
* **
|
|
20
|
+
* **pretty**
|
|
21
21
|
*
|
|
22
22
|
* Pretty format the sidebar JSON.
|
|
23
23
|
*
|
|
24
|
+
* **deprecatedItemClassName**
|
|
25
|
+
*
|
|
26
|
+
* The class name to apply to deprecated items in the sidebar. Defaults to `"typedoc-sidebar-item-deprecated"`.
|
|
27
|
+
*
|
|
24
28
|
* Please see the [sidebar guide](https:/typedoc-plugin-markdown.org/plugins/docusaurus/sidebar) for additional information on sidebar setup.
|
|
25
29
|
*
|
|
26
30
|
*/
|
|
@@ -28,4 +32,13 @@ export const sidebar = {
|
|
|
28
32
|
help: 'Configures the autogenerated Docusaurus sidebar.',
|
|
29
33
|
type: ParameterType.Mixed,
|
|
30
34
|
defaultValue: DEFAULT_SIDEBAR_OPTIONS,
|
|
35
|
+
validate(value) {
|
|
36
|
+
if (typeof value !== 'object') {
|
|
37
|
+
console.warn('[typedoc-plugin-markdown] Sidebar must be an object.');
|
|
38
|
+
}
|
|
39
|
+
const invalidKeys = Object.keys(value).filter((key) => !Object.keys(DEFAULT_SIDEBAR_OPTIONS).includes(key));
|
|
40
|
+
if (invalidKeys.length > 0) {
|
|
41
|
+
console.warn(`[typedoc-plugin-markdown] Invalid keys in sidebar options: ${invalidKeys.join(', ')}`);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
31
44
|
};
|
package/dist/options/options.js
CHANGED
|
@@ -33,7 +33,8 @@ async function generateTypedoc(context, opts) {
|
|
|
33
33
|
}
|
|
34
34
|
const { plugin, ...options } = getPluginOptions(context, opts);
|
|
35
35
|
// spawn typedoc process and pass docusaurus.config options as a string
|
|
36
|
-
|
|
36
|
+
const typedocExecutable = process.platform === 'win32' ? 'typedoc.cmd' : 'typedoc';
|
|
37
|
+
spawnSync(typedocExecutable, [
|
|
37
38
|
...plugin.flatMap((plugin) => ['--plugin', plugin]),
|
|
38
39
|
'--docusaurusConfigOptions',
|
|
39
40
|
`${JSON.stringify(options)}`,
|
package/dist/plugins/typedoc.js
CHANGED
|
@@ -46,7 +46,7 @@ export function load(app) {
|
|
|
46
46
|
if (docsPresetPath) {
|
|
47
47
|
baseDir = adjustBaseDirectory(baseDir, docsPresetPath);
|
|
48
48
|
}
|
|
49
|
-
const sidebarJson = getSidebar(output.navigation, baseDir, numberPrefixParser);
|
|
49
|
+
const sidebarJson = getSidebar(output.navigation, baseDir, sidebar, numberPrefixParser);
|
|
50
50
|
fs.writeFileSync(sidebarPath, `// @ts-check
|
|
51
51
|
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
|
|
52
52
|
const typedocSidebar = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { NavigationItem } from 'typedoc-plugin-markdown';
|
|
2
|
-
|
|
2
|
+
import { Sidebar } from '../types/options.js';
|
|
3
|
+
export declare function getSidebar(navigation: NavigationItem[], basePath: string, options: Sidebar, numberPrefixParser?: any): any;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export function getSidebar(navigation, basePath, numberPrefixParser) {
|
|
1
|
+
export function getSidebar(navigation, basePath, options, numberPrefixParser) {
|
|
2
2
|
return navigation
|
|
3
|
-
.map((navigationItem) => getNavigationItem(navigationItem, basePath, numberPrefixParser))
|
|
3
|
+
.map((navigationItem) => getNavigationItem(navigationItem, basePath, options, numberPrefixParser))
|
|
4
4
|
.filter((navItem) => Boolean(navItem));
|
|
5
5
|
}
|
|
6
|
-
function getNavigationItem(navigationItem, basePath, numberPrefixParser) {
|
|
6
|
+
function getNavigationItem(navigationItem, basePath, options, numberPrefixParser) {
|
|
7
7
|
const navigationItemPath = navigationItem.path || navigationItem.url;
|
|
8
8
|
const parsedUrl = numberPrefixParser === false
|
|
9
9
|
? navigationItemPath
|
|
@@ -25,8 +25,8 @@ function getNavigationItem(navigationItem, basePath, numberPrefixParser) {
|
|
|
25
25
|
if (navigationItem.children?.length) {
|
|
26
26
|
return {
|
|
27
27
|
type: 'category',
|
|
28
|
-
label:
|
|
29
|
-
items: getSidebar(navigationItem.children, basePath, numberPrefixParser),
|
|
28
|
+
label: navigationItem.title,
|
|
29
|
+
items: getSidebar(navigationItem.children, basePath, options, numberPrefixParser),
|
|
30
30
|
...(id && {
|
|
31
31
|
link: {
|
|
32
32
|
type: 'doc',
|
|
@@ -39,18 +39,10 @@ function getNavigationItem(navigationItem, basePath, numberPrefixParser) {
|
|
|
39
39
|
? {
|
|
40
40
|
type: 'doc',
|
|
41
41
|
id,
|
|
42
|
-
label:
|
|
42
|
+
label: navigationItem.title,
|
|
43
|
+
...(navigationItem.isDeprecated && {
|
|
44
|
+
className: options.deprecatedItemClassName,
|
|
45
|
+
}),
|
|
43
46
|
}
|
|
44
47
|
: null;
|
|
45
48
|
}
|
|
46
|
-
function getNavigationLabel(navigationItem) {
|
|
47
|
-
return navigationItem.isDeprecated
|
|
48
|
-
? strikethrough(navigationItem.title)
|
|
49
|
-
: navigationItem.title;
|
|
50
|
-
}
|
|
51
|
-
function strikethrough(label) {
|
|
52
|
-
return label
|
|
53
|
-
.split('')
|
|
54
|
-
.map((char) => char + '\u0336')
|
|
55
|
-
.join('');
|
|
56
|
-
}
|
package/package.json
CHANGED