docusaurus-plugin-typedoc 0.16.3 → 0.16.7

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
@@ -7,14 +7,11 @@ A [Docusaurus v2](https://v2.docusaurus.io/) plugin to build documentation with
7
7
 
8
8
  ## What it does?
9
9
 
10
- - Generates static TypeDoc pages in Markdown as part of the build.
11
- - Adds frontmatter to pages.
10
+ Generates static TypeDoc pages in Markdown with frontmatter as part of the Docusaurus build.
12
11
 
13
12
  ## Installation
14
13
 
15
- > Install in the same location as the Docusaurus website directory.
16
-
17
- This guide assumes that a Docusaurus project has already been setup. See [installation docs](https://v2.docusaurus.io/docs/installation).
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.
18
15
 
19
16
  ```shell
20
17
  npm install typedoc typedoc-plugin-markdown docusaurus-plugin-typedoc --save-dev
@@ -49,16 +46,21 @@ TypeDoc will be bootstraped with the Docusaurus `start` and `build` [cli command
49
46
  "build": "docusaurus build",
50
47
  ```
51
48
 
52
- Once built the docs will be available at `/docs/api` or equivalent out directory.
49
+ Once built the docs will be available at `/docs/api` (or equivalent out directory).
50
+
51
+ ### Directory structure
53
52
 
54
53
  ```
55
- website/ (docusaururs website root)
56
- ├── build/ (static site dir)
57
- ├── docs/
58
- │ ├── api/ (compiled typedoc markdown)
59
- ├── docusaurus.config.js
60
- ├── package.json
61
- ├── sidebars.js
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
62
64
  ```
63
65
 
64
66
 
@@ -88,16 +90,18 @@ TypeDoc options can also be declared:
88
90
  - Using a `typedoc.json` file.
89
91
  - Under the `typedocOptions` key in `tsconfig.json`.
90
92
 
91
- Note: Options declared in this manner will take priority and overwrite options declared in `docusaurus.config.js`.
93
+ > Note: Options declared in this manner will take priority and overwrite options declared in `docusaurus.config.js`.
92
94
 
93
95
  ### Plugin options
94
96
 
95
- | Name | Default | Description |
96
- | :---------------------- | :------ | :------------------------------------------- |
97
- | `out` | `"api"` | Output directory relative to docs directory. |
98
- | `sidebar.categoryLabel` | `API` | The sidebar parent category label. |
99
- | `sidebar.fullNames` | `false` | Display full names with module path. |
100
- | `sidebar.position` | `null` | The position of the sidebar in the tree. |
97
+ Options specific to the plugin should also be declared in the same object.
98
+
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. |
101
105
 
102
106
  ### An example configuration
103
107
 
@@ -126,13 +130,16 @@ module.exports = {
126
130
  };
127
131
  ```
128
132
 
133
+
134
+ ## Recipes
135
+
129
136
  ### Sidebar and Navbar
130
137
 
131
138
  #### Sidebar
132
139
 
133
140
  `sidebars.js` can be configured in following ways:
134
141
 
135
- 1 ) Generate the entire sidebar from file structure of your docs folder (default behaviour):
142
+ 1) Generate the entire sidebar from file structure of your docs folder (default behaviour):
136
143
 
137
144
  ```js
138
145
  module.exports = {
@@ -145,9 +152,9 @@ module.exports = {
145
152
  };
146
153
  ```
147
154
 
148
- 2 ) Alternatively, if you wish to manually control other parts of your sidebar you can use a slice for the TypeDoc sidebar.
155
+ 2) Alternatively, if you wish to manually control other parts of your sidebar you can use a slice for the TypeDoc sidebar.
149
156
 
150
- >note: `sidebar.categoryLabel` and `sidebar.position` options are ignored with this implementation)
157
+ > note: `sidebar.categoryLabel` and `sidebar.position` options are ignored with this implementation)
151
158
 
152
159
  ```js
153
160
  module.exports = {
@@ -186,7 +193,6 @@ A navbar item can be configured in `themeConfig` options in `docusaurus.config.j
186
193
 
187
194
  Please see https://docusaurus.io/docs/api/themes/configuration#navbar-items for navbar documentation.
188
195
 
189
- ## Additional config
190
196
 
191
197
  ### Multi instance
192
198
 
@@ -246,6 +252,27 @@ module.exports = {
246
252
  };
247
253
  ```
248
254
 
255
+ ### Monorepo setup
256
+
257
+ `docusaurus.config.js`
258
+
259
+ ```js
260
+ module.exports = {
261
+ plugins: [
262
+ [
263
+ 'docusaurus-plugin-typedoc',
264
+ {
265
+ entryPoints: ['../packages/package-a', '../packages/package-b'],
266
+ entryPointStrategy: 'packages',
267
+ sidebar: {
268
+ fullNames: true
269
+ },
270
+ },
271
+ ],
272
+ ],
273
+ };
274
+ ```
275
+
249
276
  ## License
250
277
 
251
278
  [MIT](https://github.com/tgreyuk/typedoc-plugin-markdown/blob/master/packages/docusaurus-plugin-typedoc/LICENSE)
package/dist/options.js CHANGED
@@ -18,6 +18,8 @@ const DEFAULT_PLUGIN_OPTIONS = {
18
18
  entryDocument: 'index.md',
19
19
  plugin: ['none'],
20
20
  watch: false,
21
+ indexSlug: undefined,
22
+ theme: 'docusaurus',
21
23
  };
22
24
  const getPluginOptions = (opts) => {
23
25
  const options = {
package/dist/plugin.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { LoadContext } from '@docusaurus/types';
2
2
  import { PluginOptions } from './types';
3
- export default function pluginDocusaurus(context: LoadContext, opts: Partial<PluginOptions>): Promise<{
3
+ export default function pluginDocusaurus(context: LoadContext, opts: Partial<PluginOptions>): {
4
4
  name: string;
5
- } | undefined>;
5
+ loadContent(): Promise<void>;
6
+ };
package/dist/plugin.js CHANGED
@@ -24,33 +24,36 @@ const typedoc_1 = require("typedoc");
24
24
  const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
25
25
  const options_1 = require("./options");
26
26
  const render_1 = require("./render");
27
+ const theme_1 = require("./theme");
27
28
  const apps = [];
28
- async function pluginDocusaurus(context, opts) {
29
- if (opts.id && !apps.includes(opts.id)) {
30
- apps.push(opts.id);
31
- const { siteDir } = context;
32
- const options = (0, options_1.getPluginOptions)(opts);
33
- const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
34
- (0, render_1.removeDir)(outputDir);
35
- const app = new typedoc_1.Application();
36
- app.options.setValue('theme', path.resolve(__dirname));
37
- (0, typedoc_plugin_markdown_1.load)(app);
38
- (0, render_1.bootstrap)(app, options);
39
- const project = app.convert();
40
- if (!project) {
41
- return;
42
- }
43
- if (options.watch) {
44
- app.convertAndWatch(async (project) => {
45
- await app.generateDocs(project, outputDir);
46
- });
47
- }
48
- else {
49
- await app.generateDocs(project, outputDir);
50
- }
51
- }
29
+ function pluginDocusaurus(context, opts) {
52
30
  return {
53
31
  name: 'docusaurus-plugin-typedoc',
32
+ async loadContent() {
33
+ if (opts.id && !apps.includes(opts.id)) {
34
+ apps.push(opts.id);
35
+ const { siteDir } = context;
36
+ const options = (0, options_1.getPluginOptions)(opts);
37
+ const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
38
+ (0, render_1.removeDir)(outputDir);
39
+ const app = new typedoc_1.Application();
40
+ app.renderer.defineTheme('docusaurus', theme_1.DocusaurusTheme);
41
+ (0, typedoc_plugin_markdown_1.load)(app);
42
+ (0, render_1.bootstrap)(app, options);
43
+ const project = app.convert();
44
+ if (!project) {
45
+ return;
46
+ }
47
+ if (options.watch) {
48
+ app.convertAndWatch(async (project) => {
49
+ await app.generateDocs(project, outputDir);
50
+ });
51
+ }
52
+ else {
53
+ await app.generateDocs(project, outputDir);
54
+ }
55
+ }
56
+ },
54
57
  };
55
58
  }
56
59
  exports.default = pluginDocusaurus;
package/dist/render.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { Application } from 'typedoc';
1
+ import { Application, ProjectReflection } from 'typedoc';
2
2
  import { PluginOptions } from './types';
3
3
  export declare const bootstrap: (app: Application, options: PluginOptions) => void;
4
+ export declare function render(project: ProjectReflection, outputDirectory: string): Promise<void>;
4
5
  export declare function removeDir(path: string): void;
package/dist/render.js CHANGED
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.removeDir = exports.bootstrap = void 0;
22
+ exports.removeDir = exports.render = exports.bootstrap = void 0;
23
23
  const fs = __importStar(require("fs"));
24
24
  const typedoc_1 = require("typedoc");
25
25
  const bootstrap = (app, options) => {
@@ -31,6 +31,9 @@ const bootstrap = (app, options) => {
31
31
  exports.bootstrap = bootstrap;
32
32
  async function render(project, outputDirectory) {
33
33
  var _a;
34
+ if (!this.prepareTheme()) {
35
+ return;
36
+ }
34
37
  const output = new typedoc_1.RendererEvent(typedoc_1.RendererEvent.BEGIN, outputDirectory, project);
35
38
  output.urls = this.theme.getUrls(project);
36
39
  this.trigger(output);
@@ -40,8 +43,8 @@ async function render(project, outputDirectory) {
40
43
  });
41
44
  this.trigger(typedoc_1.RendererEvent.END, output);
42
45
  }
43
- this.theme = void 0;
44
46
  }
47
+ exports.render = render;
45
48
  const addTypedocReaders = (app) => {
46
49
  app.options.addReader(new typedoc_1.TypeDocReader());
47
50
  app.options.addReader(new typedoc_1.TSConfigReader());
@@ -62,6 +65,9 @@ const addTypedocDeclarations = (app) => {
62
65
  app.options.addDeclaration({
63
66
  name: 'readmeTitle',
64
67
  });
68
+ app.options.addDeclaration({
69
+ name: 'indexSlug',
70
+ });
65
71
  app.options.addDeclaration({
66
72
  name: 'sidebar',
67
73
  type: typedoc_1.ParameterType.Mixed,
package/dist/theme.d.ts CHANGED
@@ -4,6 +4,7 @@ import { SidebarOptions } from './types';
4
4
  export declare class DocusaurusTheme extends MarkdownTheme {
5
5
  sidebar: SidebarOptions;
6
6
  readmeTitle: string;
7
+ indexSlug: string;
7
8
  constructor(renderer: Renderer);
8
9
  getRelativeUrl(url: string): string;
9
10
  onPageEnd(page: PageEvent<DeclarationReflection>): void;
@@ -13,6 +14,7 @@ export declare class DocusaurusTheme extends MarkdownTheme {
13
14
  getSidebarPosition(page: PageEvent<DeclarationReflection>): "0.5" | "0" | null;
14
15
  getId(page: PageEvent): string;
15
16
  getTitle(page: PageEvent): any;
17
+ getSlug(): string;
16
18
  get mappings(): {
17
19
  kind: ReflectionKind[];
18
20
  isLeaf: boolean;
package/dist/theme.js CHANGED
@@ -83,10 +83,7 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
83
83
  title: pageTitle,
84
84
  };
85
85
  if (page.url === this.entryDocument) {
86
- items = {
87
- ...items,
88
- slug: `/${path.relative(process.cwd(), this.out).replace(/\\/g, '/')}/`,
89
- };
86
+ items = { ...items, slug: this.getSlug() };
90
87
  }
91
88
  if (sidebarLabel && sidebarLabel !== pageTitle) {
92
89
  items = { ...items, sidebar_label: sidebarLabel };
@@ -137,6 +134,15 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
137
134
  }
138
135
  return (0, front_matter_1.getPageTitle)(page);
139
136
  }
137
+ getSlug() {
138
+ if (this.indexSlug) {
139
+ return this.indexSlug;
140
+ }
141
+ if (this.out === process.cwd()) {
142
+ return '/';
143
+ }
144
+ return `/${path.relative(process.cwd(), this.out).replace(/\\/g, '/')}/`;
145
+ }
140
146
  get mappings() {
141
147
  return super.mappings.map((mapping) => {
142
148
  if (mapping.kind.includes(typedoc_1.ReflectionKind.Namespace)) {
@@ -158,6 +164,9 @@ __decorate([
158
164
  __decorate([
159
165
  (0, typedoc_1.BindOption)('readmeTitle')
160
166
  ], DocusaurusTheme.prototype, "readmeTitle", void 0);
167
+ __decorate([
168
+ (0, typedoc_1.BindOption)('indexSlug')
169
+ ], DocusaurusTheme.prototype, "indexSlug", void 0);
161
170
  exports.DocusaurusTheme = DocusaurusTheme;
162
171
  const writeCategoryYaml = (categoryPath, label, position) => {
163
172
  const yaml = [`label: "${label}"`];
package/dist/types.d.ts CHANGED
@@ -14,6 +14,8 @@ export interface PluginOptions {
14
14
  hideBreadcrumbs: boolean;
15
15
  hidePageTitle: boolean;
16
16
  entryDocument: string;
17
+ indexSlug?: string;
18
+ theme?: string;
17
19
  }
18
20
  export interface FrontMatter {
19
21
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-typedoc",
3
- "version": "0.16.3",
3
+ "version": "0.16.7",
4
4
  "description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -16,8 +16,8 @@
16
16
  },
17
17
  "homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
18
18
  "peerDependencies": {
19
- "typedoc": ">=0.21.0",
20
- "typedoc-plugin-markdown": ">=3.10.0"
19
+ "typedoc": ">=0.22.0",
20
+ "typedoc-plugin-markdown": ">=3.11.10"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@docusaurus/types": "^2.0.0-beta.0"
@@ -42,5 +42,5 @@
42
42
  "typescript",
43
43
  "api"
44
44
  ],
45
- "gitHead": "9cc0d903c124638d70a0d5e94108baeae8196d41"
45
+ "gitHead": "7a9b045eaacfdafd14c3427379d410c45f6b990b"
46
46
  }