docusaurus-plugin-typedoc 1.2.3 → 1.3.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/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## Documentation
8
8
 
9
- Please visit the [https://typedoc-plugin-markdown.org/plugins/docusaurus](https://typedoc-plugin-markdown.org/plugins/docusaurus) for comprehensive documentation, including options and usage guides.
9
+ Please visit [https://typedoc-plugin-markdown.org/plugins/docusaurus](https://typedoc-plugin-markdown.org/plugins/docusaurus) for comprehensive documentation, including options and usage guides.
10
10
 
11
11
  ## License
12
12
 
@@ -4,15 +4,38 @@ import { DeclarationOption } from 'typedoc';
4
4
  *
5
5
  * Set to `false` to disable sidebar generation. Defaults to `true`.
6
6
  *
7
+ * **typescript**
8
+ *
9
+ * Set to `true` to generate a TypeScript file. Defaults to `false` (CommonJs).
10
+ *
7
11
  * **pretty**
8
12
  *
9
- * Pretty format the sidebar JSON.
13
+ * Pretty format the sidebar JSON. Defaults to `false`.
10
14
  *
11
15
  * **deprecatedItemClassName**
12
16
  *
13
17
  * The class name to apply to deprecated items in the sidebar. Defaults to `"typedoc-sidebar-item-deprecated"`.
14
18
  *
15
- * Please see the [sidebar guide](https:/typedoc-plugin-markdown.org/plugins/docusaurus/sidebar) for additional information on sidebar setup.
19
+ * Please see the [sidebar guide](/plugins/docusaurus/guides/sidebar) for additional information on sidebar setup.
20
+ *
21
+ * ```js filename="docusaurus.config.js"
22
+ * {
23
+ * plugins: [
24
+ * [
25
+ * 'docusaurus-plugin-typedoc',
26
+ * {
27
+ * "sidebar": {
28
+ * "autoConfiguration": true,
29
+ * "pretty": false,
30
+ * "typescript": false,
31
+ * "deprecatedItemClassName": "typedoc-sidebar-item-deprecated"
32
+ * }
33
+ * }
34
+ * ]
35
+ * ]
36
+ * }
37
+ *
38
+ * @omitExample
16
39
  *
17
40
  */
18
41
  export declare const sidebar: Partial<DeclarationOption>;
@@ -5,15 +5,38 @@ import { DEFAULT_SIDEBAR_OPTIONS } from './options.js';
5
5
  *
6
6
  * Set to `false` to disable sidebar generation. Defaults to `true`.
7
7
  *
8
+ * **typescript**
9
+ *
10
+ * Set to `true` to generate a TypeScript file. Defaults to `false` (CommonJs).
11
+ *
8
12
  * **pretty**
9
13
  *
10
- * Pretty format the sidebar JSON.
14
+ * Pretty format the sidebar JSON. Defaults to `false`.
11
15
  *
12
16
  * **deprecatedItemClassName**
13
17
  *
14
18
  * The class name to apply to deprecated items in the sidebar. Defaults to `"typedoc-sidebar-item-deprecated"`.
15
19
  *
16
- * Please see the [sidebar guide](https:/typedoc-plugin-markdown.org/plugins/docusaurus/sidebar) for additional information on sidebar setup.
20
+ * Please see the [sidebar guide](/plugins/docusaurus/guides/sidebar) for additional information on sidebar setup.
21
+ *
22
+ * ```js filename="docusaurus.config.js"
23
+ * {
24
+ * plugins: [
25
+ * [
26
+ * 'docusaurus-plugin-typedoc',
27
+ * {
28
+ * "sidebar": {
29
+ * "autoConfiguration": true,
30
+ * "pretty": false,
31
+ * "typescript": false,
32
+ * "deprecatedItemClassName": "typedoc-sidebar-item-deprecated"
33
+ * }
34
+ * }
35
+ * ]
36
+ * ]
37
+ * }
38
+ *
39
+ * @omitExample
17
40
  *
18
41
  */
19
42
  export const sidebar = {
@@ -1,6 +1,7 @@
1
1
  export declare const DEFAULT_SIDEBAR_OPTIONS: {
2
2
  autoConfiguration: boolean;
3
3
  pretty: boolean;
4
+ typescript: boolean;
4
5
  deprecatedItemClassName: string;
5
6
  };
6
7
  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
+ typescript: false,
5
6
  deprecatedItemClassName: 'typedoc-sidebar-item-deprecated',
6
7
  };
7
8
  const DEFAULT_PLUGIN_OPTIONS = {
@@ -3,21 +3,28 @@ import * as path from 'path';
3
3
  import { adjustBaseDirectory } from '../utils/adjust-basedir.js';
4
4
  export function writeSidebar(navigation, outputDir, sidebar, siteDir, docsPresetPath, numberPrefixParser) {
5
5
  if (sidebar?.autoConfiguration) {
6
- const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
7
- let baseDir = path
8
- .relative(siteDir, outputDir)
9
- .split(path.sep)
10
- .slice(1)
11
- .join('/');
12
- if (docsPresetPath) {
13
- baseDir = adjustBaseDirectory(baseDir, docsPresetPath);
14
- }
6
+ const sidebarFileName = sidebar.typescript
7
+ ? 'typedoc-sidebar.ts'
8
+ : 'typedoc-sidebar.cjs';
9
+ const sidebarPath = path.resolve(outputDir, sidebarFileName);
10
+ const baseDir = adjustBaseDirectory(path.relative(siteDir, outputDir).split(path.sep).join('/'), docsPresetPath || 'docs');
15
11
  const sidebarJson = getSidebar(navigation, baseDir, sidebar, numberPrefixParser);
16
- fs.writeFileSync(sidebarPath, `// @ts-check
12
+ const sidebarContent = sidebar.typescript
13
+ ? getTypescriptSidebar(sidebarJson, sidebar)
14
+ : getJsSidebar(sidebarJson, sidebar);
15
+ fs.writeFileSync(sidebarPath, sidebarContent);
16
+ }
17
+ }
18
+ function getTypescriptSidebar(sidebarJson, sidebar) {
19
+ return `import { SidebarsConfig } from '@docusaurus/plugin-content-docs';
20
+ const typedocSidebar: SidebarsConfig = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
21
+ export default typedocSidebar;`;
22
+ }
23
+ function getJsSidebar(sidebarJson, sidebar) {
24
+ return `// @ts-check
17
25
  /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
18
26
  const typedocSidebar = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
19
- module.exports = typedocSidebar.items;`);
20
- }
27
+ module.exports = typedocSidebar.items;`;
21
28
  }
22
29
  function getSidebar(navigation, basePath, options, numberPrefixParser) {
23
30
  return navigation
@@ -2,17 +2,14 @@
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;
9
5
  /**
10
6
  * Configures the autogenerated Docusaurus sidebar.
11
7
  */
12
- sidebar: Sidebar;
8
+ sidebar?: Sidebar;
13
9
  }
14
10
  export interface Sidebar {
15
11
  autoConfiguration: boolean;
16
12
  pretty: boolean;
13
+ typescript: boolean;
17
14
  deprecatedItemClassName: string;
18
15
  }
@@ -1 +1,4 @@
1
+ /*
2
+ * THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY
3
+ */
1
4
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-typedoc",
3
- "version": "1.2.3",
3
+ "version": "1.3.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"
@@ -19,14 +19,13 @@
19
19
  },
20
20
  "homepage": "http://typedoc-plugin-markdown.org/plugins/docusaurus",
21
21
  "peerDependencies": {
22
- "typedoc-plugin-markdown": ">=4.4.0"
22
+ "typedoc-plugin-markdown": ">=4.6.0"
23
23
  },
24
24
  "scripts": {
25
25
  "lint": "eslint ./src",
26
- "prebuild": "rm -rf dist && copyfiles --up 1 ./src/**/*.cjs ./dist/",
26
+ "prebuild": "rm -rf dist && prebuild-options && copyfiles --up 1 ./src/**/*.cjs ./dist/",
27
27
  "prepublishOnly": "npm run lint && npm run build",
28
28
  "build": "tsc",
29
- "pretest": "rm -rf ./test/out && docusaurus generate-typedoc",
30
29
  "test": "jest",
31
30
  "test:update": "npm run build && npm test -- -u"
32
31
  },
@@ -36,9 +35,5 @@
36
35
  "docusaurus",
37
36
  "typedoc",
38
37
  "plugin"
39
- ],
40
- "devDependencies": {
41
- "@docusaurus/core": "^3.7.0",
42
- "@docusaurus/types": "^3.7.0"
43
- }
38
+ ]
44
39
  }