docusaurus-plugin-typedoc 1.0.0-next.28 → 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 CHANGED
@@ -12,4 +12,4 @@ A Docusaurus plugin to integrate TypeDoc into a Docusaurus project.
12
12
 
13
13
  ## Documentation
14
14
 
15
- Please visit [typedoc-plugin-markdown.org](https://typedoc-plugin-markdown.org/integrations/docusaurus/introduction) for comprehensive documentation, including options and usage guides.
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
- export interface PluginOptions extends TypedocPluginMarkdownOptions {
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
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // THIS FILE IS AUTO GENERATED FROM THE OPTIONS CONFIG. DO NOT EDIT DIRECTLY.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ out: string;
3
+ hideBreadcrumbs: boolean;
4
+ hidePageHeader: boolean;
5
+ entryFileName: string;
6
+ plugin: string[];
7
+ };
8
+ export default _default;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ out: './docs/api',
5
+ hideBreadcrumbs: true,
6
+ hidePageHeader: true,
7
+ entryFileName: 'index.md',
8
+ plugin: ['typedoc-plugin-markdown'],
9
+ };
package/dist/options.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- import { Application } from 'typedoc';
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.setOptions = exports.getPluginOptions = void 0;
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
- autoConfiguration: true,
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 options = (0, options_1.getPluginOptions)(opts);
64
- const { id, sidebar, ...optionsPassedToTypeDoc } = options;
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
- app.renderer.defineTheme('docusaurus', theme_1.DocusuaurusTheme);
67
- const outputDir = app.options.getValue('out');
68
- if (context.siteConfig?.markdown?.format !== 'mdx') {
69
- app.renderer.on(typedoc_1.PageEvent.END, (event) => {
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
- const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
77
- const baseDir = path
78
- .relative(siteDir, outputDir)
79
- .split(path.sep)
80
- .slice(1)
81
- .join(path.sep);
82
- const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, baseDir, sidebar.filteredIds, docsPreset ? docsPreset[1]?.docs?.numberPrefixParser : null);
83
- fs.writeFileSync(sidebarPath, `// @ts-check
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();
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, filteredIds?: string[], numberPrefixParser?: any): any;
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, filteredIds = [], numberPrefixParser) {
4
+ function getSidebar(navigation, basePath, numberPrefixParser) {
5
5
  return navigation
6
- .map((navigationItem) => getNavigationItem(navigationItem, basePath, filteredIds, numberPrefixParser))
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, filteredIds, numberPrefixParser) {
10
+ function getNavigationItem(navigationItem, basePath, numberPrefixParser) {
11
11
  const parsedUrl = numberPrefixParser === false
12
- ? navigationItem.url
13
- : navigationItem.url?.replace(/\d+\-/g, '');
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.url) {
23
- return idParts.join('/').replace(/(.*).md/, '$1');
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, filteredIds, numberPrefixParser),
33
- ...(id && { link: { type: 'doc', 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 && !filteredIds.includes(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.28",
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": "rm -rf ./dist && tsc",
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.1.1",
41
- "@docusaurus/types": "^3.1.1"
41
+ "@docusaurus/core": "^3.2.1",
42
+ "@docusaurus/types": "^3.2.1"
42
43
  }
43
44
  }
package/dist/theme.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Reflection } from 'typedoc';
2
- import { MarkdownPageEvent, MarkdownTheme } from 'typedoc-plugin-markdown';
3
- export declare class DocusuaurusTheme extends MarkdownTheme {
4
- getRenderContext(pageEvent: MarkdownPageEvent<Reflection>): any;
5
- }
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
- }