docusaurus-plugin-typedoc 0.16.8 → 0.17.2

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
@@ -32,7 +32,7 @@ module.exports = {
32
32
  // Plugin / TypeDoc options
33
33
  {
34
34
  entryPoints: ['../src/index.ts'],
35
- tsconfig: '../tsconfig.json'
35
+ tsconfig: '../tsconfig.json',
36
36
  },
37
37
  ],
38
38
  ],
@@ -63,7 +63,6 @@ Once built the docs will be available at `/docs/api` (or equivalent out director
63
63
  ├──tsconfig.json
64
64
  ```
65
65
 
66
-
67
66
  ## Options
68
67
 
69
68
  ### TypeDoc options
@@ -80,7 +79,7 @@ tsconfig: '../tsconfig.json'
80
79
  Additional TypeDoc plugins will need to be explicitly set:
81
80
 
82
81
  ```js
83
- plugin:['typedoc-plugin-xyz']
82
+ plugin: ['typedoc-plugin-xyz'];
84
83
  ```
85
84
 
86
85
  #### Other config options
@@ -96,18 +95,19 @@ TypeDoc options can also be declared:
96
95
 
97
96
  Options specific to the plugin should also be declared in the same object.
98
97
 
99
- | Name | Default | Description |
100
- | :---------------------- | :------ | :------------------------------------------------------- |
101
- | `out` | `"api"` | Output dir relative to docs dir (use `.` for no subdir). | |
102
- | `sidebar.categoryLabel` | `API` | The sidebar parent category label. |
103
- | `sidebar.fullNames` | `false` | Display full names with module path. |
104
- | `sidebar.position` | `auto` | The position of the sidebar in the tree. |
98
+ | Name | Default | Description |
99
+ | :---------------------- | :------ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
100
+ | `out` | `"api"` | Output dir relative to docs dir (use `.` for no subdir). |
101
+ | `includeExtension` | `true` | Determines whether to preserve the `.md` extension in relative links. `true` is recommended as per [Docusaurus documentation](https://docusaurus.io/docs/docs-markdown-features#referencing-other-documents) |
102
+ | `frontmatter` | `null` | Additional frontmatter options object. See [Frontmatter](#frontmatter). |
103
+ | `sidebar.categoryLabel` | `API` | The sidebar parent category label. |
104
+ | `sidebar.fullNames` | `false` | Display full names with module path. |
105
+ | `sidebar.position` | `auto` | The position of the sidebar in the tree. |
105
106
 
106
107
  ### An example configuration
107
108
 
108
109
  ```js
109
110
  module.exports = {
110
-
111
111
  plugins: [
112
112
  [
113
113
  'docusaurus-plugin-typedoc',
@@ -115,14 +115,14 @@ module.exports = {
115
115
  // TypeDoc options
116
116
  entryPoints: ['../src/index.ts'],
117
117
  tsconfig: '../tsconfig.json',
118
- plugin:['typedoc-plugin-xyz'],
118
+ plugin: ['typedoc-plugin-xyz'],
119
119
 
120
120
  // Plugin options
121
121
  out: 'api-xyz',
122
122
  sidebar: {
123
123
  categoryLabel: 'API XYZ',
124
124
  position: 0,
125
- fullNames: true
125
+ fullNames: true,
126
126
  },
127
127
  },
128
128
  ],
@@ -130,7 +130,6 @@ module.exports = {
130
130
  };
131
131
  ```
132
132
 
133
-
134
133
  ## Recipes
135
134
 
136
135
  ### Sidebar and Navbar
@@ -139,7 +138,7 @@ module.exports = {
139
138
 
140
139
  `sidebars.js` can be configured in following ways:
141
140
 
142
- 1) Generate the entire sidebar from file structure of your docs folder (default behaviour):
141
+ 1. Generate the entire sidebar from file structure of your docs folder (default behaviour):
143
142
 
144
143
  ```js
145
144
  module.exports = {
@@ -152,7 +151,7 @@ module.exports = {
152
151
  };
153
152
  ```
154
153
 
155
- 2) Alternatively, if you wish to manually control other parts of your sidebar you can use a slice for the TypeDoc sidebar.
154
+ 2. Alternatively, if you wish to manually control other parts of your sidebar you can use a slice for the TypeDoc sidebar.
156
155
 
157
156
  > note: `sidebar.categoryLabel` and `sidebar.position` options are ignored with this implementation)
158
157
 
@@ -160,7 +159,7 @@ module.exports = {
160
159
  module.exports = {
161
160
  sidebar: {
162
161
  'Category 1': ['doc1', 'doc2', 'doc3'],
163
- 'API': [
162
+ API: [
164
163
  {
165
164
  type: 'autogenerated',
166
165
  dirName: 'api', // 'api' is the 'out' directory
@@ -193,29 +192,52 @@ A navbar item can be configured in `themeConfig` options in `docusaurus.config.j
193
192
 
194
193
  Please see https://docusaurus.io/docs/api/themes/configuration#navbar-items for navbar documentation.
195
194
 
195
+ ### Frontmatter
196
+
197
+ By default the plugin will configure minimal required [Frontmatter](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs#markdown-front-matter) configuration.
198
+ Additionally required global Frontmatter options can be passed in using the `frontmatter` options object
199
+
200
+ `docusaurus.config.js`:
201
+
202
+ ```js
203
+ plugins: [
204
+ [
205
+ 'docusaurus-plugin-typedoc',
206
+ {
207
+ // .... other plugin option
208
+ frontmatter: {
209
+ pagination_prev: null,
210
+ pagination_next: null
211
+ }
212
+ ]
213
+ ]
214
+ ```
196
215
 
197
216
  ### Multi instance
198
217
 
199
218
  It is possible to build multi TypeDoc instances by passing in multiple configs with unique ids:
200
219
 
201
220
  `docusaurus.config.js`
221
+
202
222
  ```js
203
223
  module.exports = {
204
224
  plugins: [
205
225
  [
206
226
  'docusaurus-plugin-typedoc',
207
227
  {
208
- id:'api-1',
228
+ id: 'api-1',
209
229
  entryPoints: ['../api-1/src/index.ts'],
210
230
  tsconfig: '../api-1/tsconfig.json',
231
+ out: 'api-1',
211
232
  },
212
233
  ],
213
234
  [
214
235
  'docusaurus-plugin-typedoc',
215
236
  {
216
- id:'api-2',
237
+ id: 'api-2',
217
238
  entryPoints: ['../api-2/src/index.ts'],
218
239
  tsconfig: '../api-2/tsconfig.json',
240
+ out: 'api-2',
219
241
  },
220
242
  ],
221
243
  ],
@@ -265,7 +287,7 @@ module.exports = {
265
287
  entryPoints: ['../packages/package-a', '../packages/package-b'],
266
288
  entryPointStrategy: 'packages',
267
289
  sidebar: {
268
- fullNames: true
290
+ fullNames: true,
269
291
  },
270
292
  },
271
293
  ],
package/dist/options.js CHANGED
@@ -5,6 +5,7 @@ const DEFAULT_PLUGIN_OPTIONS = {
5
5
  id: 'default',
6
6
  docsRoot: 'docs',
7
7
  out: 'api',
8
+ cleanOutputDir: true,
8
9
  sidebar: {
9
10
  fullNames: false,
10
11
  categoryLabel: 'API',
@@ -18,8 +19,10 @@ const DEFAULT_PLUGIN_OPTIONS = {
18
19
  entryDocument: 'index.md',
19
20
  plugin: ['none'],
20
21
  watch: false,
22
+ includeExtension: true,
21
23
  indexSlug: undefined,
22
24
  theme: 'docusaurus',
25
+ frontmatter: undefined,
23
26
  };
24
27
  const getPluginOptions = (opts) => {
25
28
  const options = {
package/dist/plugin.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { LoadContext } from '@docusaurus/types';
2
1
  import { PluginOptions } from './types';
3
- export default function pluginDocusaurus(context: LoadContext, opts: Partial<PluginOptions>): {
2
+ export default function pluginDocusaurus(context: any, opts: Partial<PluginOptions>): {
4
3
  name: string;
5
4
  loadContent(): Promise<void>;
6
5
  };
package/dist/plugin.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -35,7 +39,9 @@ function pluginDocusaurus(context, opts) {
35
39
  const { siteDir } = context;
36
40
  const options = (0, options_1.getPluginOptions)(opts);
37
41
  const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
38
- (0, render_1.removeDir)(outputDir);
42
+ if (opts.cleanOutputDir) {
43
+ (0, render_1.removeDir)(outputDir);
44
+ }
39
45
  const app = new typedoc_1.Application();
40
46
  app.renderer.defineTheme('docusaurus', theme_1.DocusaurusTheme);
41
47
  (0, typedoc_plugin_markdown_1.load)(app);
package/dist/render.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -68,10 +72,17 @@ const addTypedocDeclarations = (app) => {
68
72
  app.options.addDeclaration({
69
73
  name: 'indexSlug',
70
74
  });
75
+ app.options.addDeclaration({
76
+ name: 'includeExtension',
77
+ });
71
78
  app.options.addDeclaration({
72
79
  name: 'sidebar',
73
80
  type: typedoc_1.ParameterType.Mixed,
74
81
  });
82
+ app.options.addDeclaration({
83
+ name: 'frontmatter',
84
+ type: typedoc_1.ParameterType.Mixed,
85
+ });
75
86
  };
76
87
  function removeDir(path) {
77
88
  if (fs.existsSync(path)) {
package/dist/theme.d.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  import { DeclarationReflection, PageEvent, ReflectionKind, Renderer, RendererEvent } from 'typedoc';
2
2
  import { MarkdownTheme } from 'typedoc-plugin-markdown/dist/theme';
3
- import { SidebarOptions } from './types';
3
+ import { FrontMatter, SidebarOptions } from './types';
4
4
  export declare class DocusaurusTheme extends MarkdownTheme {
5
5
  sidebar: SidebarOptions;
6
6
  readmeTitle: string;
7
7
  indexSlug: string;
8
+ includeExtension: string;
9
+ frontmatter: FrontMatter;
8
10
  constructor(renderer: Renderer);
9
11
  getRelativeUrl(url: string): string;
10
12
  onPageEnd(page: PageEvent<DeclarationReflection>): void;
11
13
  onRendererEnd(renderer: RendererEvent): void;
12
- getYamlItems(page: PageEvent<DeclarationReflection>): any;
14
+ getYamlItems(page: PageEvent<DeclarationReflection>): FrontMatter;
13
15
  getSidebarLabel(page: PageEvent<DeclarationReflection>): string | undefined;
14
16
  getSidebarPosition(page: PageEvent<DeclarationReflection>): "0.5" | "0" | null;
15
17
  getId(page: PageEvent): string;
package/dist/theme.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -52,9 +56,10 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
52
56
  });
53
57
  }
54
58
  getRelativeUrl(url) {
55
- const relativeUrl = super.getRelativeUrl(url);
59
+ const re = new RegExp(this.includeExtension === 'true' ? '' : '.md', 'g');
60
+ const relativeUrl = super.getRelativeUrl(url).replace(re, '');
56
61
  if (path.basename(relativeUrl).startsWith('index')) {
57
- return relativeUrl.replace('index', '');
62
+ return relativeUrl.replace('index', '').replace('.md', '');
58
63
  }
59
64
  return relativeUrl;
60
65
  }
@@ -94,9 +99,12 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
94
99
  if (page.url === page.project.url && this.entryPoints.length > 1) {
95
100
  items = { ...items, hide_table_of_contents: true };
96
101
  }
102
+ items = { ...items, custom_edit_url: null };
103
+ if (this.frontmatter) {
104
+ items = { ...items, ...this.frontmatter };
105
+ }
97
106
  return {
98
107
  ...items,
99
- custom_edit_url: null,
100
108
  };
101
109
  }
102
110
  getSidebarLabel(page) {
@@ -167,6 +175,12 @@ __decorate([
167
175
  __decorate([
168
176
  (0, typedoc_1.BindOption)('indexSlug')
169
177
  ], DocusaurusTheme.prototype, "indexSlug", void 0);
178
+ __decorate([
179
+ (0, typedoc_1.BindOption)('includeExtension')
180
+ ], DocusaurusTheme.prototype, "includeExtension", void 0);
181
+ __decorate([
182
+ (0, typedoc_1.BindOption)('frontmatter')
183
+ ], DocusaurusTheme.prototype, "frontmatter", void 0);
170
184
  exports.DocusaurusTheme = DocusaurusTheme;
171
185
  const writeCategoryYaml = (categoryPath, label, position) => {
172
186
  const yaml = [`label: "${label}"`];
package/dist/types.d.ts CHANGED
@@ -8,24 +8,19 @@ export interface PluginOptions {
8
8
  plugin: string[];
9
9
  readme?: string;
10
10
  disableOutputCheck?: boolean;
11
+ cleanOutputDir?: boolean;
11
12
  entryPoints?: string[];
12
13
  watch: boolean;
13
14
  hideInPageTOC: boolean;
14
15
  hideBreadcrumbs: boolean;
15
16
  hidePageTitle: boolean;
16
17
  entryDocument: string;
18
+ includeExtension?: boolean;
17
19
  indexSlug?: string;
18
20
  theme?: string;
21
+ frontmatter: FrontMatter;
19
22
  }
20
- export interface FrontMatter {
21
- id: string;
22
- title: string;
23
- slug?: string;
24
- sidebar_label?: string;
25
- sidebar_position?: number;
26
- hide_title?: boolean;
27
- hide_table_of_contents?: boolean;
28
- }
23
+ export declare type FrontMatter = Record<string, string | boolean | number | null> | undefined;
29
24
  export interface SidebarOptions {
30
25
  fullNames?: boolean;
31
26
  categoryLabel: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-typedoc",
3
- "version": "0.16.8",
3
+ "version": "0.17.2",
4
4
  "description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -19,15 +19,12 @@
19
19
  "typedoc": ">=0.22.0",
20
20
  "typedoc-plugin-markdown": ">=3.11.10"
21
21
  },
22
- "devDependencies": {
23
- "@docusaurus/types": "^2.0.0-beta.0"
24
- },
25
22
  "scripts": {
26
23
  "lint": "eslint ./src --ext .ts",
27
24
  "prepublishOnly": "yarn run lint && yarn run build && yarn run test",
28
25
  "build": "rm -rf ./dist && tsc",
29
26
  "build-and-test": "yarn run build && yarn run test",
30
- "test:init": "rm -rf test/site && npx @docusaurus/init@latest init test/site classic",
27
+ "test:init": "rm -rf test/site && npx npx create-docusaurus@latest test/site classic",
31
28
  "test:demo:start": "yarn run build && cd test/site && yarn run start",
32
29
  "test:demo:build": "yarn run build && cd test/site && yarn run build && yarn run serve",
33
30
  "test": "jest --colors"
@@ -42,5 +39,5 @@
42
39
  "typescript",
43
40
  "api"
44
41
  ],
45
- "gitHead": "eb688bb8ef85b24fc873f80d6182804fcc2d2dfc"
42
+ "gitHead": "34c68d8adcb9ba75af53f35dcf830caec4020be7"
46
43
  }