docusaurus-plugin-typedoc 0.17.5 → 0.18.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
@@ -101,6 +101,7 @@ Options specific to the plugin should also be declared in the same object.
101
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
102
  | `frontmatter` | `null` | Additional frontmatter options object. See [Frontmatter](#frontmatter). |
103
103
  | `sidebar.categoryLabel` | `API` | The sidebar parent category label. |
104
+ | `sidebar.collapsed` | `true` | Whether the parent category is initially collapsed |
104
105
  | `sidebar.fullNames` | `false` | Display full names with module path. |
105
106
  | `sidebar.position` | `auto` | The position of the sidebar in the tree. |
106
107
 
@@ -121,6 +122,7 @@ module.exports = {
121
122
  out: 'api-xyz',
122
123
  sidebar: {
123
124
  categoryLabel: 'API XYZ',
125
+ collapsed: false,
124
126
  position: 0,
125
127
  fullNames: true,
126
128
  },
@@ -153,7 +155,7 @@ module.exports = {
153
155
 
154
156
  2. Alternatively, if you wish to manually control other parts of your sidebar you can use a slice for the TypeDoc sidebar.
155
157
 
156
- > note: `sidebar.categoryLabel` and `sidebar.position` options are ignored with this implementation)
158
+ > note: `sidebar.categoryLabel`, `sidebar.collapsed`, and `sidebar.position` options are ignored with this implementation)
157
159
 
158
160
  ```js
159
161
  module.exports = {
package/dist/options.js CHANGED
@@ -9,6 +9,7 @@ const DEFAULT_PLUGIN_OPTIONS = {
9
9
  sidebar: {
10
10
  fullNames: false,
11
11
  categoryLabel: 'API',
12
+ collapsed: true,
12
13
  indexLabel: undefined,
13
14
  readmeLabel: 'Readme',
14
15
  position: null,
package/dist/plugin.d.ts CHANGED
@@ -1,5 +1,7 @@
1
+ import { LoadContext } from '@docusaurus/types';
1
2
  import { PluginOptions } from './types';
2
- export default function pluginDocusaurus(context: any, opts: Partial<PluginOptions>): {
3
+ export default function pluginDocusaurus(context: LoadContext, opts: Partial<PluginOptions>): {
3
4
  name: string;
4
5
  loadContent(): Promise<void>;
6
+ extendCli(cli: any): void;
5
7
  };
package/dist/plugin.js CHANGED
@@ -36,30 +36,46 @@ function pluginDocusaurus(context, opts) {
36
36
  async loadContent() {
37
37
  if (opts.id && !apps.includes(opts.id)) {
38
38
  apps.push(opts.id);
39
- const { siteDir } = context;
40
- const options = (0, options_1.getPluginOptions)(opts);
41
- const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
42
- if (opts.cleanOutputDir) {
43
- (0, render_1.removeDir)(outputDir);
44
- }
45
- const app = new typedoc_1.Application();
46
- app.renderer.defineTheme('docusaurus', theme_1.DocusaurusTheme);
47
- (0, typedoc_plugin_markdown_1.load)(app);
48
- (0, render_1.bootstrap)(app, options);
49
- const project = app.convert();
50
- if (!project) {
51
- return;
52
- }
53
- if (options.watch) {
54
- app.convertAndWatch(async (project) => {
55
- await app.generateDocs(project, outputDir);
56
- });
57
- }
58
- else {
59
- await app.generateDocs(project, outputDir);
60
- }
39
+ generateTypedoc(context, opts);
61
40
  }
62
41
  },
42
+ extendCli(cli) {
43
+ cli
44
+ .command('generate-typedoc')
45
+ .description('(docusaurus-plugin-typedoc) Generate TypeDoc docs independently of the Docusaurus build process.')
46
+ .action(async () => {
47
+ var _a;
48
+ (_a = context.siteConfig) === null || _a === void 0 ? void 0 : _a.plugins.forEach((pluginConfig) => {
49
+ if (pluginConfig && typeof pluginConfig[1] === 'object') {
50
+ generateTypedoc(context, pluginConfig[1]);
51
+ }
52
+ });
53
+ });
54
+ },
63
55
  };
64
56
  }
65
57
  exports.default = pluginDocusaurus;
58
+ async function generateTypedoc(context, opts) {
59
+ const { siteDir } = context;
60
+ const options = (0, options_1.getPluginOptions)(opts);
61
+ const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
62
+ if (opts.cleanOutputDir) {
63
+ (0, render_1.removeDir)(outputDir);
64
+ }
65
+ const app = new typedoc_1.Application();
66
+ app.renderer.defineTheme('docusaurus', theme_1.DocusaurusTheme);
67
+ (0, typedoc_plugin_markdown_1.load)(app);
68
+ (0, render_1.bootstrap)(app, options);
69
+ const project = app.convert();
70
+ if (!project) {
71
+ return;
72
+ }
73
+ if (options.watch) {
74
+ app.convertAndWatch(async (project) => {
75
+ await app.generateDocs(project, outputDir);
76
+ });
77
+ }
78
+ else {
79
+ await app.generateDocs(project, outputDir);
80
+ }
81
+ }
package/dist/theme.js CHANGED
@@ -70,12 +70,12 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
70
70
  }
71
71
  onRendererEnd(renderer) {
72
72
  if (this.sidebar.autoConfiguration) {
73
- writeCategoryYaml(renderer.outputDirectory, this.sidebar.categoryLabel, this.sidebar.position);
73
+ writeCategoryYaml(renderer.outputDirectory, this.sidebar.categoryLabel, this.sidebar.position, this.sidebar.collapsed);
74
74
  Object.keys(groupUrlsByKind(this.getUrls(renderer.project))).forEach((group) => {
75
75
  const kind = parseInt(group);
76
76
  const mapping = this.mappings.find((mapping) => mapping.kind.includes(kind));
77
77
  if (mapping) {
78
- writeCategoryYaml(renderer.outputDirectory + '/' + mapping.directory, (0, groups_1.getKindPlural)(kind), CATEGORY_POSITION[kind]);
78
+ writeCategoryYaml(renderer.outputDirectory + '/' + mapping.directory, (0, groups_1.getKindPlural)(kind), CATEGORY_POSITION[kind], true);
79
79
  }
80
80
  });
81
81
  }
@@ -113,7 +113,7 @@ class DocusaurusTheme extends theme_1.MarkdownTheme {
113
113
  }
114
114
  getSidebarLabel(page) {
115
115
  const indexLabel = this.sidebar.indexLabel ||
116
- (this.entryPoints.length > 1 ? 'Table of contents' : 'Exports');
116
+ (this.entryPoints.length > 1 ? 'Table of Contents' : 'Exports');
117
117
  if (page.url === this.entryDocument) {
118
118
  return page.url === page.project.url
119
119
  ? indexLabel
@@ -177,11 +177,14 @@ __decorate([
177
177
  (0, typedoc_1.BindOption)('frontmatter')
178
178
  ], DocusaurusTheme.prototype, "frontmatter", void 0);
179
179
  exports.DocusaurusTheme = DocusaurusTheme;
180
- const writeCategoryYaml = (categoryPath, label, position) => {
180
+ const writeCategoryYaml = (categoryPath, label, position, collapsed) => {
181
181
  const yaml = [`label: "${label}"`];
182
182
  if (position !== null) {
183
183
  yaml.push(`position: ${position}`);
184
184
  }
185
+ if (!collapsed) {
186
+ yaml.push(`collapsed: false`);
187
+ }
185
188
  if (fs.existsSync(categoryPath)) {
186
189
  fs.writeFileSync(categoryPath + '/_category_.yml', yaml.join('\n'));
187
190
  }
package/dist/types.d.ts CHANGED
@@ -21,10 +21,11 @@ export interface PluginOptions {
21
21
  theme?: string;
22
22
  frontmatter: FrontMatter;
23
23
  }
24
- export declare type FrontMatter = Record<string, string | boolean | number | null> | undefined;
24
+ export type FrontMatter = Record<string, string | boolean | number | null> | undefined;
25
25
  export interface SidebarOptions {
26
26
  fullNames?: boolean;
27
27
  categoryLabel: string;
28
+ collapsed: boolean;
28
29
  indexLabel?: string;
29
30
  readmeLabel?: string;
30
31
  position: number | null;
@@ -35,4 +36,4 @@ export interface SidebarCategory {
35
36
  label: string;
36
37
  items: SidebarItem[];
37
38
  }
38
- export declare type SidebarItem = SidebarCategory | string;
39
+ export type SidebarItem = SidebarCategory | string;
package/package.json CHANGED
@@ -1,43 +1,42 @@
1
- {
2
- "name": "docusaurus-plugin-typedoc",
3
- "version": "0.17.5",
4
- "description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
5
- "main": "dist/index.js",
6
- "files": [
7
- "dist/"
8
- ],
9
- "bugs": {
10
- "url": "https://github.com/tgreyuk/typedoc-plugin-markdown/issues"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/tgreyuk/typedoc-plugin-markdown.git",
15
- "directory": "packages/docusaurus-plugin-typedoc"
16
- },
17
- "homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
18
- "peerDependencies": {
19
- "typedoc": ">=0.22.0",
20
- "typedoc-plugin-markdown": ">=3.11.10"
21
- },
22
- "scripts": {
23
- "lint": "eslint ./src --ext .ts",
24
- "prepublishOnly": "yarn run lint && yarn run build && yarn run test",
25
- "build": "rimraf ./dist && tsc",
26
- "build-and-test": "yarn run build && yarn run test",
27
- "test:init": "rimraf test/site && npx create-docusaurus@latest test/site classic",
28
- "test:demo:start": "yarn run build && cd test/site && yarn run start",
29
- "test:demo:build": "yarn run build && cd test/site && yarn run build && yarn run serve",
30
- "test": "jest --colors"
31
- },
32
- "author": "Thomas Grey",
33
- "license": "MIT",
34
- "keywords": [
35
- "docusaurus",
36
- "typedoc",
37
- "plugin",
38
- "markdown",
39
- "typescript",
40
- "api"
41
- ],
42
- "gitHead": "e4e2f96384fdc3d93b172c4ce64df56ba66f1528"
43
- }
1
+ {
2
+ "name": "docusaurus-plugin-typedoc",
3
+ "version": "0.18.0",
4
+ "description": "A Docusaurus v2 plugin to build API documentation with TypeDoc.",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist/"
8
+ ],
9
+ "bugs": {
10
+ "url": "https://github.com/tgreyuk/typedoc-plugin-markdown/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/tgreyuk/typedoc-plugin-markdown.git",
15
+ "directory": "packages/docusaurus-plugin-typedoc"
16
+ },
17
+ "homepage": "https://github.com/tgreyuk/typedoc-plugin-markdown/tree/master/packages/docusaurus-plugin-typedoc",
18
+ "peerDependencies": {
19
+ "typedoc": ">=0.23.0",
20
+ "typedoc-plugin-markdown": ">=3.13.0"
21
+ },
22
+ "devDependencies": {
23
+ "typedoc-plugin-markdown": "^3.13.0"
24
+ },
25
+ "scripts": {
26
+ "lint": "eslint ./src --ext .ts",
27
+ "prepublishOnly": "yarn run lint && yarn run build && yarn run test",
28
+ "build": "rm -rf ./dist && tsc",
29
+ "build-and-test": "yarn run build && yarn run test",
30
+ "test": "jest --colors"
31
+ },
32
+ "author": "Thomas Grey",
33
+ "license": "MIT",
34
+ "keywords": [
35
+ "docusaurus",
36
+ "typedoc",
37
+ "plugin",
38
+ "markdown",
39
+ "typescript",
40
+ "api"
41
+ ]
42
+ }