docusaurus-plugin-typedoc 1.0.0-next.16 → 1.0.0-next.17

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
@@ -92,7 +92,7 @@ The following typedoc-plugin-markdown options are preset with the plugin.
92
92
 
93
93
  ```json
94
94
  {
95
- "out": "api",
95
+ "out": "./docs/api",
96
96
  "hideInPageTOC": true,
97
97
  "hideBreadcrumbs": true,
98
98
  "hidePageHeader": true,
@@ -112,19 +112,11 @@ Set to `false` to disable sidebar generation. Defaults to `true`.
112
112
 
113
113
  `sidebar.filteredIds`
114
114
 
115
- Ids of pages to be filtered from the sidebar. This would typically be used to filter README or modules named index from the sidebar.
115
+ Ids of pages to be filtered from the sidebar. This would typically be used to filter README or index pages from the sidebar.
116
116
 
117
117
  `sidebar.pretty`
118
118
 
119
- Pretty format the sidebar json
120
-
121
- #### `--docsRoot`
122
-
123
- The Docusaurus docs folder root. Use `./` if no root folder specified. Defaults to `./docs`.
124
-
125
- ```shell
126
- --docsRoot <path/to/docs-dir/>
127
- ```
119
+ Pretty format the sidebar JSON.
128
120
 
129
121
  ## Sidebar
130
122
 
package/dist/models.d.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import { PluginOptions as TypedocPluginMarkdownOptions } from 'typedoc-plugin-markdown';
2
2
  export interface PluginOptions extends TypedocPluginMarkdownOptions {
3
3
  id: string;
4
- docsRoot: string;
5
4
  sidebar: Partial<SidebarOptions>;
6
5
  }
7
6
  export interface SidebarOptions {
8
7
  autoConfiguration: boolean;
9
- readmeLabel: string;
10
- indexLabel: string;
11
- categoryLabel: string;
8
+ pretty: boolean;
9
+ filteredIds: string[];
12
10
  }
package/dist/options.js CHANGED
@@ -3,14 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setOptions = exports.getPluginOptions = void 0;
4
4
  const DEFAULT_PLUGIN_OPTIONS = {
5
5
  id: 'default',
6
- docsRoot: 'docs',
7
- out: 'api',
6
+ out: './docs/api',
8
7
  hideInPageTOC: true,
9
8
  hideBreadcrumbs: true,
10
9
  hidePageHeader: true,
11
10
  entryFileName: 'index.md',
12
11
  sidebar: {
13
12
  autoConfiguration: true,
13
+ pretty: false,
14
+ filteredIds: [],
14
15
  },
15
16
  plugin: ['typedoc-plugin-markdown'],
16
17
  };
package/dist/plugin.js CHANGED
@@ -63,24 +63,31 @@ exports.default = pluginDocusaurus;
63
63
  async function generateTypedoc(context, opts) {
64
64
  const { siteDir } = context;
65
65
  const options = (0, options_1.getPluginOptions)(opts);
66
- const { id, docsRoot, sidebar, ...optionsPassedToTypeDoc } = options;
67
- const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
66
+ const { id, sidebar, ...optionsPassedToTypeDoc } = options;
67
+ const app = await typedoc_1.Application.bootstrapWithPlugins(optionsPassedToTypeDoc);
68
+ const outputDir = app.options.getValue('out');
68
69
  if (options.cleanOutputDir) {
69
70
  removeDir(outputDir);
70
71
  }
71
- const app = await typedoc_1.Application.bootstrapWithPlugins(optionsPassedToTypeDoc);
72
72
  app.renderer.on(typedoc_1.PageEvent.END, (event) => {
73
73
  var _a;
74
74
  event.contents = (_a = event.contents) === null || _a === void 0 ? void 0 : _a.replace(/\\</g, '<');
75
75
  });
76
- app.renderer.postRenderAsyncJobs.push(async (output) => {
77
- const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
78
- const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, options.out);
79
- fs.writeFileSync(sidebarPath, `// @ts-check
76
+ if (sidebar === null || sidebar === void 0 ? void 0 : sidebar.autoConfiguration) {
77
+ app.renderer.postRenderAsyncJobs.push(async (output) => {
78
+ const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
79
+ const baseDir = path
80
+ .relative(siteDir, outputDir)
81
+ .split('/')
82
+ .slice(1)
83
+ .join('/');
84
+ const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, baseDir, sidebar.filteredIds);
85
+ fs.writeFileSync(sidebarPath, `// @ts-check
80
86
  /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
81
- const typedocSidebar = { items: ${JSON.stringify(sidebarJson)}};
87
+ const typedocSidebar = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
82
88
  module.exports = typedocSidebar.items;`);
83
- });
89
+ });
90
+ }
84
91
  const project = await app.convert();
85
92
  // if project is undefined typedoc has a problem - error logging will be supplied by typedoc.
86
93
  if (!project) {
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): any;
2
+ export declare function getSidebar(navigation: NavigationItem[], basePath: string, filteredIds?: string[]): any;
package/dist/sidebar.js CHANGED
@@ -1,15 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSidebar = void 0;
4
- function getSidebar(navigation, basePath) {
4
+ function getSidebar(navigation, basePath, filteredIds = []) {
5
5
  return navigation
6
- .map((navigationItem) => {
7
- return getNavigationItem(navigationItem, basePath);
8
- })
6
+ .map((navigationItem) => getNavigationItem(navigationItem, basePath, filteredIds))
9
7
  .filter((navItem) => Boolean(navItem));
10
8
  }
11
9
  exports.getSidebar = getSidebar;
12
- function getNavigationItem(navigationItem, basePath) {
10
+ function getNavigationItem(navigationItem, basePath, filteredIds) {
13
11
  var _a;
14
12
  const id = navigationItem.url
15
13
  ? `${basePath}/${navigationItem.url}`.replace(/(.*).md/, '$1')
@@ -18,11 +16,11 @@ function getNavigationItem(navigationItem, basePath) {
18
16
  return {
19
17
  type: 'category',
20
18
  label: navigationItem.title,
21
- items: getSidebar(navigationItem.children, basePath),
19
+ items: getSidebar(navigationItem.children, basePath, filteredIds),
22
20
  ...(id && { link: { type: 'doc', id } }),
23
21
  };
24
22
  }
25
- return id
23
+ return id && !filteredIds.includes(id)
26
24
  ? {
27
25
  type: 'doc',
28
26
  id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-typedoc",
3
- "version": "1.0.0-next.16",
3
+ "version": "1.0.0-next.17",
4
4
  "description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
18
18
  "peerDependencies": {
19
- "typedoc-plugin-markdown": ">=4.0.0-next.21"
19
+ "typedoc-plugin-markdown": ">=4.0.0-next.22"
20
20
  },
21
21
  "scripts": {
22
22
  "lint": "eslint ./src --ext .ts",