docusaurus-plugin-typedoc 1.0.0-next.8 → 1.0.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.
package/README.md CHANGED
@@ -1,298 +1,19 @@
1
1
  # docusaurus-plugin-typedoc
2
2
 
3
- A [Docusaurus v2](https://v2.docusaurus.io/) plugin to build documentation with [TypeDoc](https://github.com/TypeStrong/typedoc).
3
+ [![npm](https://img.shields.io/npm/v/docusaurus-plugin-typedoc.svg?logo=npm)](https://www.npmjs.com/package/docusaurus-plugin-typedoc) [![Build Status](https://github.com/typedoc2md/typedoc-plugin-markdown/actions/workflows/ci.docusaurus-plugin-typedoc.yml/badge.svg?branch=main&style=flat-square)](https://github.com/typedoc2md/typedoc-plugin-markdown/actions/workflows/ci.docusaurus-plugin-typedoc.yml)
4
4
 
5
- [![npm](https://img.shields.io/npm/v/docusaurus-plugin-typedoc.svg)](https://www.npmjs.com/package/docusaurus-plugin-typedoc)
6
- ![CI](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml/badge.svg?branch=master)
7
-
8
- ## What it does?
9
-
10
- Generates static TypeDoc pages in Markdown with frontmatter as part of the Docusaurus build.
5
+ > A Docusaurus plugin to integrate TypeDoc ( + typedoc-plugin-markdown ) into a Docusaurus project.
11
6
 
12
7
  ## Installation
13
8
 
14
- > Install [Docusaurus](https://v2.docusaurus.io/docs/installation) in the root of your project and install the plugin dependencies in the same location as the Docusaurus website directory.
15
-
16
9
  ```shell
17
- npm install typedoc typedoc-plugin-markdown docusaurus-plugin-typedoc --save-dev
18
- ```
19
-
20
- ## Usage
21
-
22
- ### Config
23
-
24
- Add the plugin to `docusaurus.config.js` and specify the required options (see [options](#options)).
25
-
26
- ```js
27
- module.exports = {
28
- plugins: [
29
- [
30
- 'docusaurus-plugin-typedoc',
31
-
32
- // Plugin / TypeDoc options
33
- {
34
- entryPoints: ['../src/index.ts'],
35
- tsconfig: '../tsconfig.json',
36
- },
37
- ],
38
- ],
39
- };
40
- ```
41
-
42
- TypeDoc will be bootstraped with the Docusaurus `start` and `build` [cli commands](https://v2.docusaurus.io/docs/cli):
43
-
44
- ```javascript
45
- "start": "docusaurus start",
46
- "build": "docusaurus build",
47
- ```
48
-
49
- Once built the docs will be available at `/docs/api` (or equivalent out directory).
50
-
51
- ### Directory structure
52
-
53
- ```
54
- ├── docusauruss-website
55
- ├── build/ (static site dir)
56
- ├── docs/
57
- │ ├── api/ (compiled typedoc markdown)
58
- ├── docusaurus.config.js
59
- ├── package.json
60
- ├── sidebars.js
61
- ├──package.json
62
- ├──src (typescript source files)
63
- ├──tsconfig.json
64
- ```
65
-
66
- ## Options
67
-
68
- ### TypeDoc options
69
-
70
- To configure TypeDoc, pass any relevant [TypeDoc options](https://typedoc.org/guides/options/) to the config.
71
-
72
- At a minimum the `entryPoints` and `tsconfig` options will need to be set.
73
-
74
- ```js
75
- entryPoints: ['../src/index.ts'],
76
- tsconfig: '../tsconfig.json'
77
- ```
78
-
79
- Additional TypeDoc plugins will need to be explicitly set:
80
-
81
- ```js
82
- plugin: ['typedoc-plugin-xyz'];
83
- ```
84
-
85
- #### Other config options
86
-
87
- TypeDoc options can also be declared:
88
-
89
- - Using a `typedoc.json` file.
90
- - Under the `typedocOptions` key in `tsconfig.json`.
91
-
92
- > Note: Options declared in this manner will take priority and overwrite options declared in `docusaurus.config.js`.
93
-
94
- ### Plugin options
95
-
96
- Options specific to the plugin should also be declared in the same object.
97
-
98
- | Name | Default | Description |
99
- | :---------------------- | :------ | :------------------------------------------------------- |
100
- | `out` | `"api"` | Output dir relative to docs dir (use `.` for no subdir). |
101
- | `sidebar.categoryLabel` | `API` | The sidebar parent category label. |
102
- | `sidebar.fullNames` | `false` | Display full names with module path. |
103
- | `sidebar.position` | `auto` | The position of the sidebar in the tree. |
104
-
105
- ### An example configuration
106
-
107
- ```js
108
- module.exports = {
109
- plugins: [
110
- [
111
- 'docusaurus-plugin-typedoc',
112
- {
113
- // TypeDoc options
114
- entryPoints: ['../src/index.ts'],
115
- tsconfig: '../tsconfig.json',
116
- plugin: ['typedoc-plugin-xyz'],
117
-
118
- // Plugin options
119
- out: 'api-xyz',
120
- sidebar: {
121
- categoryLabel: 'API XYZ',
122
- position: 0,
123
- fullNames: true,
124
- },
125
- },
126
- ],
127
- ],
128
- };
129
- ```
130
-
131
- ## Recipes
132
-
133
- ### Sidebar and Navbar
134
-
135
- #### Sidebar
136
-
137
- `sidebars.js` can be configured in following ways:
138
-
139
- 1. Generate the entire sidebar from file structure of your docs folder (default behaviour):
140
-
141
- ```js
142
- module.exports = {
143
- sidebar: [
144
- {
145
- type: 'autogenerated',
146
- dirName: '.', // '.' means the docs folder
147
- },
148
- ],
149
- };
150
- ```
151
-
152
- 2. Alternatively, if you wish to manually control other parts of your sidebar you can use a slice for the TypeDoc sidebar.
153
-
154
- > note: `sidebar.categoryLabel` and `sidebar.position` options are ignored with this implementation)
155
-
156
- ```js
157
- module.exports = {
158
- sidebar: {
159
- 'Category 1': ['doc1', 'doc2', 'doc3'],
160
- API: [
161
- {
162
- type: 'autogenerated',
163
- dirName: 'api', // 'api' is the 'out' directory
164
- },
165
- ],
166
- },
167
- };
168
- ```
169
-
170
- Please see https://docusaurus.io/docs/sidebar for sidebar documentation.
171
-
172
- #### Navbar
173
-
174
- A navbar item can be configured in `themeConfig` options in `docusaurus.config.js`:
175
-
176
- ```js
177
- themeConfig: {
178
- navbar: {
179
- items: [
180
- {
181
- to: 'docs/api/', // 'api' is the 'out' directory
182
- activeBasePath: 'docs',
183
- label: 'API',
184
- position: 'left',
185
- },
186
- ],
187
- },
188
- },
189
- ```
190
-
191
- Please see https://docusaurus.io/docs/api/themes/configuration#navbar-items for navbar documentation.
192
-
193
- ### Frontmatter
194
-
195
- By default the plugin will configure minimal required [Frontmatter](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs#markdown-front-matter) configuration.
196
- Additionally required global Frontmatter options can be passed in using the `frontmatterGlobals` options object
197
-
198
- `docusaurus.config.js`:
199
-
200
- ```js
201
- plugins: [
202
- [
203
- 'docusaurus-plugin-typedoc',
204
- {
205
- // .... other plugin option
206
- frontmatterGlobals: {
207
- pagination_prev: null,
208
- pagination_next: null
209
- }
210
- ]
211
- ]
212
- ```
213
-
214
- ### Multi instance
215
-
216
- It is possible to build multi TypeDoc instances by passing in multiple configs with unique ids:
217
-
218
- `docusaurus.config.js`
219
-
220
- ```js
221
- module.exports = {
222
- plugins: [
223
- [
224
- 'docusaurus-plugin-typedoc',
225
- {
226
- id: 'api-1',
227
- entryPoints: ['../api-1/src/index.ts'],
228
- tsconfig: '../api-1/tsconfig.json',
229
- out: 'api-1',
230
- },
231
- ],
232
- [
233
- 'docusaurus-plugin-typedoc',
234
- {
235
- id: 'api-2',
236
- entryPoints: ['../api-2/src/index.ts'],
237
- tsconfig: '../api-2/tsconfig.json',
238
- out: 'api-2',
239
- },
240
- ],
241
- ],
242
- };
243
- ```
244
-
245
- ### Watch mode
246
-
247
- Watching files is supported by passing in the `watch: true` option see [https://typedoc.org/guides/options/#watch](https://typedoc.org/guides/options/#watch).
248
-
249
- Targetting the option in development mode only can be achieved using Node.js Environment Variables:
250
-
251
- `package.json`
252
-
253
- ```json
254
- "start": "TYPEDOC_WATCH=true docusaurus start",
255
- "build": "TYPEDOC_WATCH=false docusaurus build",
256
- ```
257
-
258
- `docusaurus.config.js`
259
-
260
- ```js
261
- module.exports = {
262
- plugins: [
263
- [
264
- 'docusaurus-plugin-typedoc',
265
- {
266
- entryPoints: ['../src/index.ts'],
267
- tsconfig: '../tsconfig.json',
268
- watch: process.env.TYPEDOC_WATCH,
269
- },
270
- ],
271
- ],
272
- };
273
- ```
274
-
275
- ### Monorepo setup
10
+ npm install docusaurus-plugin-typedoc --save-dev
11
+ ```
276
12
 
277
- `docusaurus.config.js`
13
+ ## Documentation
278
14
 
279
- ```js
280
- module.exports = {
281
- plugins: [
282
- [
283
- 'docusaurus-plugin-typedoc',
284
- {
285
- entryPoints: ['../packages/package-a', '../packages/package-b'],
286
- entryPointStrategy: 'packages',
287
- sidebar: {
288
- fullNames: true,
289
- },
290
- },
291
- ],
292
- ],
293
- };
294
- ```
15
+ 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.
295
16
 
296
17
  ## License
297
18
 
298
- [MIT](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/docusaurus-plugin-typedoc/LICENSE)
19
+ MIT
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { default } from './plugin.docusaurus';
2
- export { load } from './plugin.typedoc';
1
+ export { PluginOptions } from './models';
2
+ export { default } from './plugin';
package/dist/index.js CHANGED
@@ -3,8 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.load = exports.default = void 0;
7
- var plugin_docusaurus_1 = require("./plugin.docusaurus");
8
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(plugin_docusaurus_1).default; } });
9
- var plugin_typedoc_1 = require("./plugin.typedoc");
10
- Object.defineProperty(exports, "load", { enumerable: true, get: function () { return plugin_typedoc_1.load; } });
6
+ exports.default = void 0;
7
+ var plugin_1 = require("./plugin");
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(plugin_1).default; } });
package/dist/models.d.ts CHANGED
@@ -1,24 +1,5 @@
1
- import { TypedocPluginMarkdownOptions } from 'typedoc-plugin-markdown';
2
- export interface PluginOptions extends TypedocPluginMarkdownOptions {
1
+ import { PluginOptions as TypedocPluginMarkdownOptions } from 'typedoc-plugin-markdown';
2
+ import { PluginOptions as DocusaurusOptions } from './options/option-types';
3
+ export interface PluginOptions extends TypedocPluginMarkdownOptions, DocusaurusOptions {
3
4
  id: string;
4
- docsRoot: string;
5
- sidebar: SidebarOptions;
6
5
  }
7
- export interface SidebarOptions {
8
- categoryLabel: string;
9
- collapsed: boolean;
10
- position: number | null;
11
- autoConfiguration: boolean;
12
- }
13
- export interface SidebarCategory {
14
- type: string;
15
- label: string;
16
- items: SidebarItem[];
17
- }
18
- export interface CategoryYamlOptions {
19
- path: string;
20
- label: string;
21
- position: number | null;
22
- collapsed: boolean;
23
- }
24
- export type SidebarItem = SidebarCategory | string;
@@ -0,0 +1,21 @@
1
+ import { ParameterType } from 'typedoc';
2
+ /**
3
+ * **sidebar.autoConfiguration**
4
+ *
5
+ * Set to `false` to disable sidebar generation. Defaults to `true`.
6
+ *
7
+ * **sidebar.pretty**
8
+ *
9
+ * Pretty format the sidebar JSON.
10
+ *
11
+ * Please see the [sidebar guide](/plugins/docusaurus/guide/sidebar) for additional information on sidebar setup.
12
+ *
13
+ */
14
+ export declare const sidebar: {
15
+ help: string;
16
+ type: ParameterType;
17
+ defaultValue: {
18
+ autoConfiguration: boolean;
19
+ pretty: boolean;
20
+ };
21
+ };
@@ -0,0 +1,22 @@
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
+ * **sidebar.autoConfiguration**
8
+ *
9
+ * Set to `false` to disable sidebar generation. Defaults to `true`.
10
+ *
11
+ * **sidebar.pretty**
12
+ *
13
+ * Pretty format the sidebar JSON.
14
+ *
15
+ * Please see the [sidebar guide](/plugins/docusaurus/guide/sidebar) for additional information on sidebar setup.
16
+ *
17
+ */
18
+ exports.sidebar = {
19
+ help: 'Configures the autogenerated Docusaurus sidebar.',
20
+ type: typedoc_1.ParameterType.Mixed,
21
+ defaultValue: options_1.DEFAULT_SIDEBAR_OPTIONS,
22
+ };
@@ -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,2 +1,5 @@
1
- import { PluginOptions } from './models';
2
- export declare const getPluginOptions: (opts: Partial<PluginOptions>) => PluginOptions;
1
+ export declare const DEFAULT_SIDEBAR_OPTIONS: {
2
+ autoConfiguration: boolean;
3
+ pretty: boolean;
4
+ };
5
+ export declare function getPluginOptions(opts: Record<string, any>): Record<string, any>;
package/dist/options.js CHANGED
@@ -1,26 +1,22 @@
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.getPluginOptions = void 0;
4
- const plugin = require.resolve('docusaurus-plugin-typedoc');
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
+ };
5
12
  const DEFAULT_PLUGIN_OPTIONS = {
13
+ ...presets_1.default,
6
14
  id: 'default',
7
- docsRoot: 'docs',
8
- out: 'api',
9
15
  sidebar: {
10
- categoryLabel: 'API',
11
- collapsed: true,
12
- position: null,
13
- autoConfiguration: true,
16
+ ...exports.DEFAULT_SIDEBAR_OPTIONS,
14
17
  },
15
- hideInPageTOC: true,
16
- hideBreadcrumbs: true,
17
- entryDocument: 'index.md',
18
- watch: false,
19
- enableFrontmatter: true,
20
- numberPrefixOutput: true,
21
- plugin: [plugin],
22
18
  };
23
- const getPluginOptions = (opts) => {
19
+ function getPluginOptions(opts) {
24
20
  const options = {
25
21
  ...DEFAULT_PLUGIN_OPTIONS,
26
22
  ...opts,
@@ -28,8 +24,10 @@ const getPluginOptions = (opts) => {
28
24
  ...DEFAULT_PLUGIN_OPTIONS.sidebar,
29
25
  ...opts.sidebar,
30
26
  },
31
- plugin: [DEFAULT_PLUGIN_OPTIONS.plugin, ...(opts.plugin || [])],
27
+ plugin: [
28
+ ...new Set([...DEFAULT_PLUGIN_OPTIONS.plugin, ...(opts.plugin || [])]),
29
+ ],
32
30
  };
33
31
  return options;
34
- };
32
+ }
35
33
  exports.getPluginOptions = getPluginOptions;
@@ -1,6 +1,5 @@
1
- import { PluginOptions } from './models';
2
- export default function pluginDocusaurus(context: any, opts: Partial<PluginOptions>): {
1
+ import { PluginOptions } from '.';
2
+ export default function pluginDocusaurus(context: any, opts: Partial<PluginOptions>): Promise<{
3
3
  name: string;
4
- loadContent(): Promise<void>;
5
4
  extendCli(cli: any): void;
6
- };
5
+ }>;
package/dist/plugin.js ADDED
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const fs = __importStar(require("fs"));
27
+ const path = __importStar(require("path"));
28
+ const typedoc_1 = require("typedoc");
29
+ const options_1 = require("./options");
30
+ const options = __importStar(require("./options/declarations"));
31
+ const sidebar_1 = require("./sidebar");
32
+ // store list of plugin ids when running multiple instances
33
+ const apps = [];
34
+ async function pluginDocusaurus(context, opts) {
35
+ const PLUGIN_NAME = 'docusaurus-plugin-typedoc';
36
+ if (opts.id && !apps.includes(opts.id)) {
37
+ apps.push(opts.id);
38
+ await generateTypedoc(context, opts);
39
+ }
40
+ return {
41
+ name: PLUGIN_NAME,
42
+ extendCli(cli) {
43
+ cli
44
+ .command('generate-typedoc')
45
+ .description(`[${PLUGIN_NAME}] Generate TypeDoc docs independently of the Docusaurus build process.`)
46
+ .action(async () => {
47
+ context.siteConfig?.plugins.forEach((pluginConfig) => {
48
+ // Check PluginConfig is typed to [string, PluginOptions]
49
+ if (pluginConfig && typeof pluginConfig[1] === 'object') {
50
+ generateTypedoc(context, pluginConfig[1]);
51
+ }
52
+ });
53
+ });
54
+ },
55
+ };
56
+ }
57
+ exports.default = pluginDocusaurus;
58
+ /**
59
+ * Initiates a new typedoc Application bootstrapped with plugin options
60
+ */
61
+ async function generateTypedoc(context, opts) {
62
+ const { siteDir } = context;
63
+ const pluginOptions = (0, options_1.getPluginOptions)(opts);
64
+ const { id, sidebar, ...optionsPassedToTypeDoc } = pluginOptions;
65
+ const app = await typedoc_1.Application.bootstrapWithPlugins(optionsPassedToTypeDoc);
66
+ Object.entries(options).forEach(([name, option]) => {
67
+ app.options.addDeclaration({
68
+ name,
69
+ ...option,
70
+ });
71
+ });
72
+ // attempt to handle docusaurus linkify bug https://github.com/facebook/docusaurus/issues/9048
73
+ app.renderer.on(typedoc_1.PageEvent.END, (event) => {
74
+ event.contents = event.contents
75
+ ?.replace(/\)\.\[/g, ') . [')
76
+ .replace(/\\<\[/g, ' \\<[');
77
+ });
78
+ const outputDir = app.options.getValue('out');
79
+ if (sidebar?.autoConfiguration) {
80
+ const docsPreset = context.siteConfig?.presets?.find((preset) => Boolean(preset[1]?.docs));
81
+ app.renderer.postRenderAsyncJobs.push(async (output) => {
82
+ if (output.navigation) {
83
+ const sidebarPath = path.resolve(outputDir, 'typedoc-sidebar.cjs');
84
+ const baseDir = path
85
+ .relative(siteDir, outputDir)
86
+ .split(path.sep)
87
+ .slice(1)
88
+ .join(path.sep);
89
+ const sidebarJson = (0, sidebar_1.getSidebar)(output.navigation, baseDir, docsPreset ? docsPreset[1]?.docs?.numberPrefixParser : null);
90
+ fs.writeFileSync(sidebarPath, `// @ts-check
91
+ /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
92
+ const typedocSidebar = { items: ${JSON.stringify(sidebarJson, null, sidebar.pretty ? 2 : 0)}};
93
+ module.exports = typedocSidebar.items;`);
94
+ }
95
+ });
96
+ }
97
+ const project = await app.convert();
98
+ // if project is undefined typedoc has a problem - error logging will be supplied by typedoc.
99
+ if (!project) {
100
+ if (app.options.getValue('skipErrorChecking')) {
101
+ return;
102
+ }
103
+ console.error('[docusaurus-plugin-typedoc] TypeDoc exited with an error. Use the "skipErrorChecking" option to disable TypeDoc error checking.');
104
+ process.exit(1);
105
+ }
106
+ if (app.options.getValue('watch')) {
107
+ app.convertAndWatch(async (project) => {
108
+ await app.generateDocs(project, outputDir);
109
+ });
110
+ }
111
+ else {
112
+ await app.generateDocs(project, outputDir);
113
+ }
114
+ }
@@ -0,0 +1,2 @@
1
+ import { NavigationItem } from 'typedoc-plugin-markdown';
2
+ export declare function getSidebar(navigation: NavigationItem[], basePath: string, numberPrefixParser?: any): any;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSidebar = void 0;
4
+ function getSidebar(navigation, basePath, numberPrefixParser) {
5
+ return navigation
6
+ .map((navigationItem) => getNavigationItem(navigationItem, basePath, numberPrefixParser))
7
+ .filter((navItem) => Boolean(navItem));
8
+ }
9
+ exports.getSidebar = getSidebar;
10
+ function getNavigationItem(navigationItem, basePath, numberPrefixParser) {
11
+ const parsedUrl = numberPrefixParser === false
12
+ ? navigationItem.path
13
+ : navigationItem.path?.replace(/\d+\-/g, '');
14
+ const getId = () => {
15
+ const idParts = [];
16
+ if (basePath.length > 0) {
17
+ idParts.push(basePath);
18
+ }
19
+ if (parsedUrl) {
20
+ idParts.push(parsedUrl.replace(/\\/g, '/'));
21
+ }
22
+ if (navigationItem.path) {
23
+ return idParts.join('/').replace(/(.*)\.\w+$/, '$1');
24
+ }
25
+ return null;
26
+ };
27
+ const id = getId();
28
+ if (navigationItem.children?.length) {
29
+ return {
30
+ type: 'category',
31
+ label: `${navigationItem.title}`,
32
+ items: getSidebar(navigationItem.children, basePath, numberPrefixParser),
33
+ ...(id && {
34
+ link: {
35
+ type: 'doc',
36
+ id,
37
+ },
38
+ }),
39
+ };
40
+ }
41
+ return id
42
+ ? {
43
+ type: 'doc',
44
+ id,
45
+ label: `${navigationItem.title}`,
46
+ }
47
+ : null;
48
+ }
package/package.json CHANGED
@@ -1,38 +1,41 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-typedoc",
3
- "version": "1.0.0-next.8",
4
- "description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
3
+ "version": "1.0.0",
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/"
8
8
  ],
9
9
  "bugs": {
10
- "url": "https://github.com/tgreyuk/typedoc-plugin-markdown/issues"
10
+ "url": "https://github.com/typedoc2md/typedoc-plugin-markdown/issues"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/tgreyuk/typedoc-plugin-markdown.git",
14
+ "url": "git+https://github.com/typedoc2md/typedoc-plugin-markdown.git",
15
15
  "directory": "packages/docusaurus-plugin-typedoc"
16
16
  },
17
- "homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
17
+ "homepage": "http://typedoc.org/plugins/docusaurus",
18
18
  "peerDependencies": {
19
- "typedoc-plugin-markdown": ">=4.0.0-next.9"
19
+ "typedoc-plugin-markdown": ">=4.0.0"
20
20
  },
21
21
  "scripts": {
22
22
  "lint": "eslint ./src --ext .ts",
23
- "prepublishOnly": "npm run lint && npm run build && npm run test",
24
- "build": "rm -rf ./dist && tsc",
25
- "build-and-test": "npm run build && npm run test",
26
- "test": "jest --colors"
23
+ "prebuild": "rm -rf dist && prebuild-options",
24
+ "prepublishOnly": "npm run lint && npm run build",
25
+ "build": "tsc",
26
+ "pretest": "rm -rf ./test/out && docusaurus generate-typedoc",
27
+ "test": "jest",
28
+ "test:update": "npm run build && npm test -- -u"
27
29
  },
28
30
  "author": "Thomas Grey",
29
31
  "license": "MIT",
30
32
  "keywords": [
31
33
  "docusaurus",
32
34
  "typedoc",
33
- "plugin",
34
- "markdown",
35
- "typescript",
36
- "api"
37
- ]
35
+ "plugin"
36
+ ],
37
+ "devDependencies": {
38
+ "@docusaurus/core": "^3.2.1",
39
+ "@docusaurus/types": "^3.2.1"
40
+ }
38
41
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2016 Thomas Grey
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const path = __importStar(require("path"));
27
- const typedoc_1 = require("typedoc");
28
- const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
29
- const options_1 = require("./options");
30
- const apps = [];
31
- function pluginDocusaurus(context, opts) {
32
- return {
33
- name: 'docusaurus-plugin-typedoc',
34
- async loadContent() {
35
- if (opts.id && !apps.includes(opts.id)) {
36
- apps.push(opts.id);
37
- generateTypedoc(context, opts);
38
- }
39
- },
40
- extendCli(cli) {
41
- cli
42
- .command('generate-typedoc')
43
- .description('(docusaurus-plugin-typedoc) Generate TypeDoc docs independently of the Docusaurus build process.')
44
- .action(async () => {
45
- var _a;
46
- (_a = context.siteConfig) === null || _a === void 0 ? void 0 : _a.plugins.forEach((pluginConfig) => {
47
- if (pluginConfig && typeof pluginConfig[1] === 'object') {
48
- generateTypedoc(context, pluginConfig[1]);
49
- }
50
- });
51
- });
52
- },
53
- };
54
- }
55
- exports.default = pluginDocusaurus;
56
- async function generateTypedoc(context, opts) {
57
- const { siteDir } = context;
58
- const options = (0, options_1.getPluginOptions)(opts);
59
- const { id, docsRoot, ...optionsPassedToTypeDoc } = options;
60
- const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
61
- const app = new typedoc_1.Application();
62
- app.options.addReader(new typedoc_1.TypeDocReader());
63
- app.options.addReader(new typedoc_1.TSConfigReader());
64
- (0, typedoc_plugin_markdown_1.load)(app);
65
- await app.bootstrapWithPlugins(optionsPassedToTypeDoc);
66
- const project = app.convert();
67
- if (!project) {
68
- return;
69
- }
70
- if (options.watch) {
71
- app.convertAndWatch(async (project) => {
72
- await app.generateDocs(project, outputDir);
73
- });
74
- }
75
- else {
76
- await app.generateDocs(project, outputDir);
77
- }
78
- }
@@ -1,2 +0,0 @@
1
- import { Application } from 'typedoc';
2
- export declare function load(app: Application): void;
@@ -1,79 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.load = void 0;
27
- const fs = __importStar(require("fs"));
28
- const path = __importStar(require("path"));
29
- const typedoc_1 = require("typedoc");
30
- function load(app) {
31
- app.options.addDeclaration({
32
- name: 'sidebar',
33
- type: typedoc_1.ParameterType.Mixed,
34
- });
35
- app.renderer.on(typedoc_1.PageEvent.END, (page) => {
36
- if (page.contents) {
37
- page.contents = page.contents.replace(/\\</g, '<');
38
- }
39
- });
40
- app.renderer.postRenderAsyncJobs.push(async (renderer) => {
41
- var _a;
42
- const sidebar = app.options.getValue('sidebar');
43
- if (sidebar.autoConfiguration) {
44
- writeCategoryYaml({
45
- path: renderer.outputDirectory,
46
- label: sidebar.categoryLabel,
47
- position: sidebar.position,
48
- collapsed: sidebar.collapsed,
49
- });
50
- }
51
- const urlGroups = (_a = renderer.urls) === null || _a === void 0 ? void 0 : _a.filter((urlMapping) => {
52
- return urlMapping.model instanceof typedoc_1.ReflectionGroup;
53
- });
54
- urlGroups === null || urlGroups === void 0 ? void 0 : urlGroups.forEach((urlGroup) => {
55
- const groupUrl = path.join(renderer.outputDirectory, urlGroup.url);
56
- writeCategoryYaml({
57
- path: groupUrl,
58
- label: urlGroup.model.title,
59
- position: null,
60
- collapsed: sidebar.collapsed,
61
- });
62
- });
63
- app.logger.verbose('[docusaurus-plugin-typedoc] _category_.yml files written' +
64
- renderer.outputDirectory);
65
- });
66
- }
67
- exports.load = load;
68
- function writeCategoryYaml(categoryYamlOptions) {
69
- const yaml = [`label: "${categoryYamlOptions.label}"`];
70
- if (categoryYamlOptions.position !== null) {
71
- yaml.push(`position: ${categoryYamlOptions.position}`);
72
- }
73
- if (!categoryYamlOptions.collapsed) {
74
- yaml.push(`collapsed: false`);
75
- }
76
- if (fs.existsSync(categoryYamlOptions.path)) {
77
- fs.writeFileSync(categoryYamlOptions.path + '/_category_.yml', yaml.join('\n'));
78
- }
79
- }