docusaurus-plugin-typedoc 1.2.3 → 1.3.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.
@@ -4,15 +4,19 @@ 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.
16
20
  *
17
21
  */
18
22
  export declare const sidebar: Partial<DeclarationOption>;
@@ -5,15 +5,19 @@ 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.
17
21
  *
18
22
  */
19
23
  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,7 +3,10 @@ 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');
6
+ const sidebarFileName = sidebar.typescript
7
+ ? 'typedoc-sidebar.ts'
8
+ : 'typedoc-sidebar.cjs';
9
+ const sidebarPath = path.resolve(outputDir, sidebarFileName);
7
10
  let baseDir = path
8
11
  .relative(siteDir, outputDir)
9
12
  .split(path.sep)
@@ -13,11 +16,22 @@ export function writeSidebar(navigation, outputDir, sidebar, siteDir, docsPreset
13
16
  baseDir = adjustBaseDirectory(baseDir, docsPresetPath);
14
17
  }
15
18
  const sidebarJson = getSidebar(navigation, baseDir, sidebar, numberPrefixParser);
16
- fs.writeFileSync(sidebarPath, `// @ts-check
19
+ const sidebarContent = sidebar.typescript
20
+ ? getTypescriptSidebar(sidebarJson, sidebar)
21
+ : getJsSidebar(sidebarJson, sidebar);
22
+ fs.writeFileSync(sidebarPath, sidebarContent);
23
+ }
24
+ }
25
+ function getTypescriptSidebar(sidebarJson, sidebar) {
26
+ return `import { SidebarsConfig } from '@docusaurus/plugin-content-docs';
27
+ const typedocSidebar: SidebarsConfig = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
28
+ export default typedocSidebar;`;
29
+ }
30
+ function getJsSidebar(sidebarJson, sidebar) {
31
+ return `// @ts-check
17
32
  /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
18
33
  const typedocSidebar = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
19
- module.exports = typedocSidebar.items;`);
20
- }
34
+ module.exports = typedocSidebar.items;`;
21
35
  }
22
36
  function getSidebar(navigation, basePath, options, numberPrefixParser) {
23
37
  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.0",
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,11 +19,11 @@
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
29
  "pretest": "rm -rf ./test/out && docusaurus generate-typedoc",