docusaurus-plugin-typedoc 1.0.0-next.5 → 1.0.0-next.8

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/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export { default } from './plugin';
1
+ export { default } from './plugin.docusaurus';
2
+ export { load } from './plugin.typedoc';
package/dist/index.js CHANGED
@@ -3,6 +3,8 @@ 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.default = void 0;
7
- var plugin_1 = require("./plugin");
8
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(plugin_1).default; } });
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; } });
@@ -0,0 +1,24 @@
1
+ import { TypedocPluginMarkdownOptions } from 'typedoc-plugin-markdown';
2
+ export interface PluginOptions extends TypedocPluginMarkdownOptions {
3
+ id: string;
4
+ docsRoot: string;
5
+ sidebar: SidebarOptions;
6
+ }
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;
package/dist/options.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { PluginOptions } from './types';
1
+ import { PluginOptions } from './models';
2
2
  export declare const getPluginOptions: (opts: Partial<PluginOptions>) => PluginOptions;
package/dist/options.js CHANGED
@@ -1,27 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPluginOptions = void 0;
4
+ const plugin = require.resolve('docusaurus-plugin-typedoc');
4
5
  const DEFAULT_PLUGIN_OPTIONS = {
5
6
  id: 'default',
6
7
  docsRoot: 'docs',
7
8
  out: 'api',
8
- cleanOutputDir: true,
9
9
  sidebar: {
10
- fullNames: false,
11
10
  categoryLabel: 'API',
12
11
  collapsed: true,
13
- indexLabel: 'Overview',
14
12
  position: null,
15
13
  autoConfiguration: true,
16
14
  },
17
15
  hideInPageTOC: true,
18
16
  hideBreadcrumbs: true,
19
- hidePageTitle: false,
20
17
  entryDocument: 'index.md',
21
- plugin: ['none'],
22
18
  watch: false,
23
- theme: 'docusaurus',
24
19
  enableFrontmatter: true,
20
+ numberPrefixOutput: true,
21
+ plugin: [plugin],
25
22
  };
26
23
  const getPluginOptions = (opts) => {
27
24
  const options = {
@@ -31,6 +28,7 @@ const getPluginOptions = (opts) => {
31
28
  ...DEFAULT_PLUGIN_OPTIONS.sidebar,
32
29
  ...opts.sidebar,
33
30
  },
31
+ plugin: [DEFAULT_PLUGIN_OPTIONS.plugin, ...(opts.plugin || [])],
34
32
  };
35
33
  return options;
36
34
  };
@@ -1,4 +1,4 @@
1
- import { PluginOptions } from './types';
1
+ import { PluginOptions } from './models';
2
2
  export default function pluginDocusaurus(context: any, opts: Partial<PluginOptions>): {
3
3
  name: string;
4
4
  loadContent(): Promise<void>;
@@ -27,8 +27,6 @@ const path = __importStar(require("path"));
27
27
  const typedoc_1 = require("typedoc");
28
28
  const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
29
29
  const options_1 = require("./options");
30
- const render_1 = require("./render");
31
- const theme_1 = require("./theme");
32
30
  const apps = [];
33
31
  function pluginDocusaurus(context, opts) {
34
32
  return {
@@ -58,14 +56,13 @@ exports.default = pluginDocusaurus;
58
56
  async function generateTypedoc(context, opts) {
59
57
  const { siteDir } = context;
60
58
  const options = (0, options_1.getPluginOptions)(opts);
59
+ const { id, docsRoot, ...optionsPassedToTypeDoc } = options;
61
60
  const outputDir = path.resolve(siteDir, options.docsRoot, options.out);
62
- if (opts.cleanOutputDir) {
63
- (0, render_1.removeDir)(outputDir);
64
- }
65
61
  const app = new typedoc_1.Application();
66
- app.renderer.defineTheme('docusaurus', theme_1.DocusaurusTheme);
62
+ app.options.addReader(new typedoc_1.TypeDocReader());
63
+ app.options.addReader(new typedoc_1.TSConfigReader());
67
64
  (0, typedoc_plugin_markdown_1.load)(app);
68
- (0, render_1.bootstrap)(app, options);
65
+ await app.bootstrapWithPlugins(optionsPassedToTypeDoc);
69
66
  const project = app.convert();
70
67
  if (!project) {
71
68
  return;
@@ -0,0 +1,2 @@
1
+ import { Application } from 'typedoc';
2
+ export declare function load(app: Application): void;
@@ -0,0 +1,79 @@
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docusaurus-plugin-typedoc",
3
- "version": "1.0.0-next.5",
3
+ "version": "1.0.0-next.8",
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.6"
19
+ "typedoc-plugin-markdown": ">=4.0.0-next.9"
20
20
  },
21
21
  "scripts": {
22
22
  "lint": "eslint ./src --ext .ts",
@@ -1,11 +0,0 @@
1
- export declare const CATEGORY_POSITION: {
2
- 2: number;
3
- 4: number;
4
- 8: number;
5
- 128: number;
6
- 256: number;
7
- 4194304: number;
8
- 32: number;
9
- 64: number;
10
- 2097152: number;
11
- };
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CATEGORY_POSITION = void 0;
4
- const typedoc_1 = require("typedoc");
5
- exports.CATEGORY_POSITION = {
6
- [typedoc_1.ReflectionKind.Module]: 1,
7
- [typedoc_1.ReflectionKind.Namespace]: 1,
8
- [typedoc_1.ReflectionKind.Enum]: 2,
9
- [typedoc_1.ReflectionKind.Class]: 3,
10
- [typedoc_1.ReflectionKind.Interface]: 4,
11
- [typedoc_1.ReflectionKind.TypeAlias]: 5,
12
- [typedoc_1.ReflectionKind.Variable]: 6,
13
- [typedoc_1.ReflectionKind.Function]: 7,
14
- [typedoc_1.ReflectionKind.ObjectLiteral]: 8,
15
- };
package/dist/render.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Application, ProjectReflection } from 'typedoc';
2
- import { PluginOptions } from './types';
3
- export declare const bootstrap: (app: Application, options: PluginOptions) => void;
4
- export declare function render(project: ProjectReflection, outputDirectory: string): Promise<void>;
5
- export declare function removeDir(path: string): void;
package/dist/render.js DELETED
@@ -1,81 +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.removeDir = exports.render = exports.bootstrap = void 0;
27
- const fs = __importStar(require("fs"));
28
- const typedoc_1 = require("typedoc");
29
- const bootstrap = (app, options) => {
30
- addTypedocReaders(app);
31
- addTypedocDeclarations(app);
32
- app.renderer.render = render;
33
- app.bootstrap(options);
34
- };
35
- exports.bootstrap = bootstrap;
36
- async function render(project, outputDirectory) {
37
- var _a;
38
- if (!this.prepareTheme()) {
39
- return;
40
- }
41
- const output = new typedoc_1.RendererEvent(typedoc_1.RendererEvent.BEGIN, outputDirectory, project);
42
- output.urls = this.theme.getUrls(project);
43
- this.trigger(output);
44
- await Promise.all(this.preRenderAsyncJobs.map((job) => job(output)));
45
- this.preRenderAsyncJobs = [];
46
- if (!output.isDefaultPrevented) {
47
- (_a = output.urls) === null || _a === void 0 ? void 0 : _a.forEach((mapping) => {
48
- this.renderDocument(...output.createPageEvent(mapping));
49
- });
50
- await Promise.all(this.postRenderAsyncJobs.map((job) => job(output)));
51
- this.postRenderAsyncJobs = [];
52
- this.trigger(typedoc_1.RendererEvent.END, output);
53
- }
54
- }
55
- exports.render = render;
56
- const addTypedocReaders = (app) => {
57
- app.options.addReader(new typedoc_1.TypeDocReader());
58
- app.options.addReader(new typedoc_1.TSConfigReader());
59
- };
60
- const addTypedocDeclarations = (app) => {
61
- app.options.addDeclaration({
62
- name: 'id',
63
- });
64
- app.options.addDeclaration({
65
- name: 'docsRoot',
66
- });
67
- app.options.addDeclaration({
68
- name: 'siteDir',
69
- });
70
- app.options.addDeclaration({
71
- name: 'globalsTitle',
72
- });
73
- app.options.addDeclaration({
74
- name: 'sidebar',
75
- type: typedoc_1.ParameterType.Mixed,
76
- });
77
- };
78
- function removeDir(path) {
79
- fs.rmSync(path, { recursive: true, force: true });
80
- }
81
- exports.removeDir = removeDir;
package/dist/theme.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { DeclarationReflection, PageEvent, Renderer, RendererEvent } from 'typedoc';
2
- import { MarkdownTheme } from 'typedoc-plugin-markdown';
3
- import { SidebarOptions } from './types';
4
- export declare class DocusaurusTheme extends MarkdownTheme {
5
- sidebar: SidebarOptions;
6
- constructor(renderer: Renderer);
7
- onPageEnd(page: PageEvent<DeclarationReflection>): void;
8
- onRendererEnd(renderer: RendererEvent): void;
9
- loopAndWriteCategories(path: string, level?: number): void;
10
- writeCategoryYaml: (categoryPath: string, label: string, position: number | null, collapsed: boolean, generatedIndex: boolean) => void;
11
- }
package/dist/theme.js DELETED
@@ -1,103 +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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.DocusaurusTheme = void 0;
33
- const fs = __importStar(require("fs"));
34
- const typedoc_1 = require("typedoc");
35
- const typedoc_plugin_markdown_1 = require("typedoc-plugin-markdown");
36
- const navigation_1 = require("./navigation");
37
- class DocusaurusTheme extends typedoc_plugin_markdown_1.MarkdownTheme {
38
- constructor(renderer) {
39
- super(renderer);
40
- this.writeCategoryYaml = (categoryPath, label, position, collapsed, generatedIndex) => {
41
- const yaml = [`label: "${label}"`];
42
- if (position !== null) {
43
- yaml.push(`position: ${position}`);
44
- }
45
- if (!collapsed) {
46
- yaml.push(`collapsed: false`);
47
- }
48
- if (generatedIndex) {
49
- yaml.push(`link:
50
- type: "generated-index"
51
- title: "${label}"`);
52
- }
53
- if (fs.existsSync(categoryPath)) {
54
- fs.writeFileSync(categoryPath + '/_category_.yml', yaml.join('\n'));
55
- }
56
- };
57
- this.listenTo(this.application.renderer, {
58
- [typedoc_1.PageEvent.END]: this.onPageEnd,
59
- [typedoc_1.RendererEvent.END]: this.onRendererEnd,
60
- });
61
- }
62
- onPageEnd(page) {
63
- if (page.contents) {
64
- page.contents = page.contents.replace(/\\</g, '<');
65
- }
66
- }
67
- onRendererEnd(renderer) {
68
- if (this.sidebar.autoConfiguration) {
69
- this.writeCategoryYaml(renderer.outputDirectory, this.sidebar.categoryLabel, this.sidebar.position, this.sidebar.collapsed, false);
70
- this.loopAndWriteCategories(renderer.outputDirectory);
71
- const globalsFile = this.getRenderContext().globalsFile;
72
- const globalsPath = `${renderer.outputDirectory}/${this.getRenderContext().globalsFile}`;
73
- if (fs.existsSync(globalsPath)) {
74
- fs.renameSync(globalsPath, `${renderer.outputDirectory}/01-${globalsFile}`);
75
- }
76
- }
77
- }
78
- loopAndWriteCategories(path, level = 0) {
79
- const directory = fs.readdirSync(path);
80
- directory.forEach((segment) => {
81
- const fullPath = `${path}/${segment}`;
82
- const isDirectory = fs.lstatSync(fullPath).isDirectory();
83
- if (isDirectory) {
84
- const mapping = Object.entries(this.mappings)
85
- .filter((entry) => {
86
- return entry[1].directory === segment;
87
- })
88
- .map((entry) => entry[1])[0];
89
- const subdirectory = fs.readdirSync(fullPath);
90
- const containsDir = subdirectory.some((item) => fs.lstatSync(`${fullPath}/${item}`).isDirectory());
91
- if ((mapping && !containsDir) ||
92
- (mapping === null || mapping === void 0 ? void 0 : mapping.kind) === typedoc_1.ReflectionKind.Namespace) {
93
- this.writeCategoryYaml(fullPath, typedoc_1.ReflectionKind.pluralString(mapping.kind), navigation_1.CATEGORY_POSITION[mapping.kind], true, true);
94
- }
95
- this.loopAndWriteCategories(fullPath);
96
- }
97
- });
98
- }
99
- }
100
- __decorate([
101
- (0, typedoc_1.BindOption)('sidebar')
102
- ], DocusaurusTheme.prototype, "sidebar", void 0);
103
- exports.DocusaurusTheme = DocusaurusTheme;
package/dist/types.d.ts DELETED
@@ -1,36 +0,0 @@
1
- export interface PluginOptions {
2
- id: string;
3
- docsRoot: string;
4
- out: string;
5
- sidebar: SidebarOptions;
6
- readmeTitle?: string;
7
- globalsTitle?: string;
8
- plugin: string[];
9
- readme?: string;
10
- disableOutputCheck?: boolean;
11
- cleanOutputDir?: boolean;
12
- entryPoints?: string[];
13
- watch: boolean;
14
- hideInPageTOC: boolean;
15
- hideBreadcrumbs: boolean;
16
- hidePageTitle: boolean;
17
- entryDocument: string;
18
- includeExtension?: boolean;
19
- theme?: string;
20
- enableFrontmatter: boolean;
21
- }
22
- export type FrontMatter = Record<string, string | boolean | number | null> | undefined;
23
- export interface SidebarOptions {
24
- fullNames?: boolean;
25
- categoryLabel: string;
26
- collapsed: boolean;
27
- indexLabel?: string;
28
- position: number | null;
29
- autoConfiguration: boolean;
30
- }
31
- export interface SidebarCategory {
32
- type: string;
33
- label: string;
34
- items: SidebarItem[];
35
- }
36
- export type SidebarItem = SidebarCategory | string;
File without changes