docusaurus-plugin-typedoc 1.0.0-next.7 → 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 +2 -1
- package/dist/index.js +5 -3
- package/dist/models.d.ts +6 -0
- package/dist/options.js +3 -2
- package/dist/{plugin.js → plugin.docusaurus.js} +4 -6
- package/dist/plugin.typedoc.d.ts +2 -0
- package/dist/plugin.typedoc.js +79 -0
- package/package.json +2 -2
- package/dist/render.d.ts +0 -3
- package/dist/render.js +0 -25
- package/dist/theme.d.ts +0 -11
- package/dist/theme.js +0 -95
- /package/dist/{plugin.d.ts → plugin.docusaurus.d.ts} +0 -0
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
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(
|
|
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; } });
|
package/dist/models.d.ts
CHANGED
|
@@ -15,4 +15,10 @@ export interface SidebarCategory {
|
|
|
15
15
|
label: string;
|
|
16
16
|
items: SidebarItem[];
|
|
17
17
|
}
|
|
18
|
+
export interface CategoryYamlOptions {
|
|
19
|
+
path: string;
|
|
20
|
+
label: string;
|
|
21
|
+
position: number | null;
|
|
22
|
+
collapsed: boolean;
|
|
23
|
+
}
|
|
18
24
|
export type SidebarItem = SidebarCategory | string;
|
package/dist/options.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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',
|
|
@@ -13,12 +14,11 @@ const DEFAULT_PLUGIN_OPTIONS = {
|
|
|
13
14
|
},
|
|
14
15
|
hideInPageTOC: true,
|
|
15
16
|
hideBreadcrumbs: true,
|
|
16
|
-
hidePageTitle: false,
|
|
17
17
|
entryDocument: 'index.md',
|
|
18
18
|
watch: false,
|
|
19
19
|
enableFrontmatter: true,
|
|
20
20
|
numberPrefixOutput: true,
|
|
21
|
-
|
|
21
|
+
plugin: [plugin],
|
|
22
22
|
};
|
|
23
23
|
const getPluginOptions = (opts) => {
|
|
24
24
|
const options = {
|
|
@@ -28,6 +28,7 @@ const getPluginOptions = (opts) => {
|
|
|
28
28
|
...DEFAULT_PLUGIN_OPTIONS.sidebar,
|
|
29
29
|
...opts.sidebar,
|
|
30
30
|
},
|
|
31
|
+
plugin: [DEFAULT_PLUGIN_OPTIONS.plugin, ...(opts.plugin || [])],
|
|
31
32
|
};
|
|
32
33
|
return options;
|
|
33
34
|
};
|
|
@@ -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,13 +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
61
|
const app = new typedoc_1.Application();
|
|
63
|
-
app.
|
|
62
|
+
app.options.addReader(new typedoc_1.TypeDocReader());
|
|
63
|
+
app.options.addReader(new typedoc_1.TSConfigReader());
|
|
64
64
|
(0, typedoc_plugin_markdown_1.load)(app);
|
|
65
|
-
|
|
66
|
-
(0, render_1.addTypedocDeclarations)(app);
|
|
67
|
-
await app.bootstrapWithPlugins(options);
|
|
65
|
+
await app.bootstrapWithPlugins(optionsPassedToTypeDoc);
|
|
68
66
|
const project = app.convert();
|
|
69
67
|
if (!project) {
|
|
70
68
|
return;
|
|
@@ -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.
|
|
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.
|
|
19
|
+
"typedoc-plugin-markdown": ">=4.0.0-next.9"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"lint": "eslint ./src --ext .ts",
|
package/dist/render.d.ts
DELETED
package/dist/render.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addTypedocDeclarations = exports.addTypedocReaders = void 0;
|
|
4
|
-
const typedoc_1 = require("typedoc");
|
|
5
|
-
function addTypedocReaders(app) {
|
|
6
|
-
app.options.addReader(new typedoc_1.TypeDocReader());
|
|
7
|
-
app.options.addReader(new typedoc_1.TSConfigReader());
|
|
8
|
-
}
|
|
9
|
-
exports.addTypedocReaders = addTypedocReaders;
|
|
10
|
-
function addTypedocDeclarations(app) {
|
|
11
|
-
app.options.addDeclaration({
|
|
12
|
-
name: 'id',
|
|
13
|
-
});
|
|
14
|
-
app.options.addDeclaration({
|
|
15
|
-
name: 'docsRoot',
|
|
16
|
-
});
|
|
17
|
-
app.options.addDeclaration({
|
|
18
|
-
name: 'globalsTitle',
|
|
19
|
-
});
|
|
20
|
-
app.options.addDeclaration({
|
|
21
|
-
name: 'sidebar',
|
|
22
|
-
type: typedoc_1.ParameterType.Mixed,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
exports.addTypedocDeclarations = addTypedocDeclarations;
|
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 './models';
|
|
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,95 +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
|
-
class DocusaurusTheme extends typedoc_plugin_markdown_1.MarkdownTheme {
|
|
37
|
-
constructor(renderer) {
|
|
38
|
-
super(renderer);
|
|
39
|
-
this.writeCategoryYaml = (categoryPath, label, position, collapsed, generatedIndex) => {
|
|
40
|
-
const yaml = [`label: "${label}"`];
|
|
41
|
-
if (position !== null) {
|
|
42
|
-
yaml.push(`position: ${position}`);
|
|
43
|
-
}
|
|
44
|
-
if (!collapsed) {
|
|
45
|
-
yaml.push(`collapsed: false`);
|
|
46
|
-
}
|
|
47
|
-
if (generatedIndex) {
|
|
48
|
-
yaml.push(`link:
|
|
49
|
-
type: "generated-index"
|
|
50
|
-
title: "${label}"`);
|
|
51
|
-
}
|
|
52
|
-
if (fs.existsSync(categoryPath)) {
|
|
53
|
-
fs.writeFileSync(categoryPath + '/_category_.yml', yaml.join('\n'));
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
this.listenTo(this.application.renderer, {
|
|
57
|
-
[typedoc_1.PageEvent.END]: this.onPageEnd,
|
|
58
|
-
[typedoc_1.RendererEvent.END]: this.onRendererEnd,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
onPageEnd(page) {
|
|
62
|
-
if (page.contents) {
|
|
63
|
-
page.contents = page.contents.replace(/\\</g, '<');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
onRendererEnd(renderer) {
|
|
67
|
-
if (this.sidebar.autoConfiguration) {
|
|
68
|
-
this.writeCategoryYaml(renderer.outputDirectory, this.sidebar.categoryLabel, this.sidebar.position, this.sidebar.collapsed, false);
|
|
69
|
-
this.loopAndWriteCategories(renderer.outputDirectory);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
loopAndWriteCategories(path, level = 0) {
|
|
73
|
-
const directory = fs.readdirSync(path);
|
|
74
|
-
directory.forEach((segment) => {
|
|
75
|
-
const fullPath = `${path}/${segment}`;
|
|
76
|
-
const isDirectory = fs.lstatSync(fullPath).isDirectory();
|
|
77
|
-
if (isDirectory) {
|
|
78
|
-
const mapping = Object.entries(this.mappings)
|
|
79
|
-
.filter((entry) => {
|
|
80
|
-
return entry[1].directory === segment.slice(3);
|
|
81
|
-
})
|
|
82
|
-
.map((entry) => entry[1])[0];
|
|
83
|
-
const subdirectory = fs.readdirSync(fullPath);
|
|
84
|
-
if (mapping && !subdirectory.includes(`${mapping === null || mapping === void 0 ? void 0 : mapping.directory}.md`)) {
|
|
85
|
-
this.writeCategoryYaml(fullPath, typedoc_1.ReflectionKind.pluralString(mapping.kind), null, true, true);
|
|
86
|
-
}
|
|
87
|
-
this.loopAndWriteCategories(fullPath);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
__decorate([
|
|
93
|
-
(0, typedoc_1.BindOption)('sidebar')
|
|
94
|
-
], DocusaurusTheme.prototype, "sidebar", void 0);
|
|
95
|
-
exports.DocusaurusTheme = DocusaurusTheme;
|
|
File without changes
|