docusaurus-plugin-typedoc 1.1.1 → 1.2.1

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 CHANGED
@@ -1,2 +1,5 @@
1
+ /**
2
+ * @module core
3
+ */
1
4
  export { PluginOptions } from './models.js';
2
5
  export { default } from './plugins/docusaurus.js';
@@ -8,14 +8,18 @@ import { DeclarationOption } from 'typedoc';
8
8
  */
9
9
  export declare const docusaurusConfigOptions: Partial<DeclarationOption>;
10
10
  /**
11
- * **sidebar.autoConfiguration**
11
+ * **autoConfiguration**
12
12
  *
13
13
  * Set to `false` to disable sidebar generation. Defaults to `true`.
14
14
  *
15
- * **sidebar.pretty**
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
- * **sidebar.autoConfiguration**
16
+ * **autoConfiguration**
17
17
  *
18
18
  * Set to `false` to disable sidebar generation. Defaults to `true`.
19
19
  *
20
- * **sidebar.pretty**
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
  };
@@ -1,5 +1,6 @@
1
1
  export declare const DEFAULT_SIDEBAR_OPTIONS: {
2
2
  autoConfiguration: boolean;
3
3
  pretty: boolean;
4
+ deprecatedItemClassName: string;
4
5
  };
5
6
  export declare function getPluginOptions(context: any, opts: Record<string, any>): Record<string, any>;
@@ -2,6 +2,7 @@ import { presets } from './presets.js';
2
2
  export const DEFAULT_SIDEBAR_OPTIONS = {
3
3
  autoConfiguration: true,
4
4
  pretty: false,
5
+ deprecatedItemClassName: 'typedoc-sidebar-item-deprecated',
5
6
  };
6
7
  const DEFAULT_PLUGIN_OPTIONS = {
7
8
  ...presets,
@@ -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)}};
@@ -11,10 +11,8 @@ export interface PluginOptions {
11
11
  */
12
12
  sidebar: Sidebar;
13
13
  }
14
- /**
15
- *
16
- */
17
14
  export interface Sidebar {
18
15
  autoConfiguration: boolean;
19
16
  pretty: boolean;
17
+ deprecatedItemClassName: string;
20
18
  }
@@ -1,2 +1,3 @@
1
1
  import { NavigationItem } from 'typedoc-plugin-markdown';
2
- export declare function getSidebar(navigation: NavigationItem[], basePath: string, numberPrefixParser?: any): any;
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: `${navigationItem.title}`,
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,7 +39,10 @@ function getNavigationItem(navigationItem, basePath, numberPrefixParser) {
39
39
  ? {
40
40
  type: 'doc',
41
41
  id,
42
- label: `${navigationItem.title}`,
42
+ label: navigationItem.title,
43
+ ...(navigationItem.isDeprecated && {
44
+ className: options.deprecatedItemClassName,
45
+ }),
43
46
  }
44
47
  : null;
45
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-typedoc",
3
- "version": "1.1.1",
3
+ "version": "1.2.1",
4
4
  "description": "A Docusaurus plugin to integrate TypeDoc ( + typedoc-plugin-markdown ) into a Docusaurus project.",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "homepage": "http://typedoc-plugin-markdown.org/plugins/docusaurus",
22
22
  "peerDependencies": {
23
- "typedoc-plugin-markdown": ">=4.3.0"
23
+ "typedoc-plugin-markdown": ">=4.4.0"
24
24
  },
25
25
  "scripts": {
26
26
  "lint": "eslint ./src",