feat: Finally packaging with ncc

This commit is contained in:
Laegel
2021-03-22 00:18:23 +01:00
parent 87b50c07b1
commit 1a631e6924
31 changed files with 154024 additions and 882 deletions

153921
dist/index.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,35 +0,0 @@
const core = require("@actions/core");
const { rmdir } = require("fs").promises;
const { default: generate } = require("../src/plugin");
(async () => {
try {
// Where your docs live, should be the folder containing the crates docs
const originPath = core.getInput("originPath"); // e.g. "/path/to/project/src/";
const sidebarFile = core.getInput("sidebarFile");
// Where you'll save your MD files
const targetPath = core.getInput("targetPath"); // e.g. "/path/to/docusaurus/website/docs/api/js/";
const docusaurusPath = core.getInput("docusaurusPath");
await rmdir(targetPath, { recursive: true });
await generate(docusaurusPath, {
entryPoints: originPath + "src",
out: targetPath,
entryDocument: "index.md",
hideInPageTOC: true,
hideBreadcrumbs: true,
watch: false,
tsconfig: originPath + "tsconfig.json",
sidebar: {
sidebarFile,
},
readme: "none",
});
console.log("Tasks completed!");
} catch (error) {
core.setFailed(error.message);
}
})();

View File

@@ -1,13 +0,0 @@
{
"name": "typedocusaurus-action",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"run-source": "node index.js",
"build": "ncc build index.js -o dist"
},
"dependencies": {
"@actions/core": "^1.2.6",
"@zeit/ncc": "^0.22.3"
}
}

View File

@@ -1,13 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@actions/core@^1.2.6":
version "1.2.6"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09"
integrity sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==
"@zeit/ncc@^0.22.3":
version "0.22.3"
resolved "https://registry.yarnpkg.com/@zeit/ncc/-/ncc-0.22.3.tgz#fca6b86b4454ce7a7e1e7e755165ec06457f16cd"
integrity sha512-jnCLpLXWuw/PAiJiVbLjA8WBC0IJQbFeUwF4I9M+23MvIxTxk5pD4Q8byQBSPmHQjz5aBoA7AKAElQxMpjrCLQ==

View File

@@ -3,10 +3,18 @@
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"scripts": {
"run-source": "node index.js",
"pkg": "ncc build src/index.ts -o dist"
},
"devDependencies": {
"@types/node": "^14.14.35",
"typedoc": "^0.20.30",
"typedoc-plugin-markdown": "^3.6.0",
"typescript": "^4.2.3"
"@zeit/ncc": "^0.27.0",
"override-require": "^1.1.1",
"typescript": "^4.2.3",
"tslib": "^2.1.0"
},
"dependencies": {
"@actions/core": "^1.2.6"
}
}
}

31
src/front-matter.d.ts vendored
View File

@@ -1,31 +0,0 @@
import { RendererComponent } from 'typedoc/dist/lib/output/components';
import { PageEvent } from 'typedoc/dist/lib/output/events';
import { Sidebar } from './types';
export interface FrontMatterVars {
[key: string]: string | number | boolean;
}
/**
* Prepends YAML block to a string
* @param contents - the string to prepend
* @param vars - object of required front matter variables
*/
export declare const prependYAML: (contents: string, vars: FrontMatterVars) => string;
/**
* Returns the page title as rendered in the document h1(# title)
* @param page
*/
export declare const getPageTitle: (page: PageEvent) => any;
export declare class FrontMatterComponent extends RendererComponent {
out: string;
sidebar: Sidebar;
globalsTitle: string;
readmeTitle: string;
entryDocument: string;
globalsFile: string;
initialize(): void;
onPageEnd(page: PageEvent): void;
getYamlItems(page: PageEvent): any;
getSidebarLabel(page: PageEvent): any;
getId(page: PageEvent): string;
getTitle(page: PageEvent): any;
}

View File

@@ -1,123 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FrontMatterComponent = exports.getPageTitle = exports.prependYAML = void 0;
const path = require("path");
const typedoc_1 = require("typedoc");
const components_1 = require("typedoc/dist/lib/converter/components");
const components_2 = require("typedoc/dist/lib/output/components");
const events_1 = require("typedoc/dist/lib/output/events");
const reflection_title_1 = require("typedoc-plugin-markdown/dist/resources/helpers/reflection-title");
/**
* Prepends YAML block to a string
* @param contents - the string to prepend
* @param vars - object of required front matter variables
*/
const prependYAML = (contents, vars) => {
return contents
.replace(/^/, toYAML(vars) + '\n\n')
.replace(/[\r\n]{3,}/g, '\n\n');
};
exports.prependYAML = prependYAML;
/**
* Returns the page title as rendered in the document h1(# title)
* @param page
*/
const getPageTitle = (page) => {
return reflection_title_1.reflectionTitle.call(page, false);
};
exports.getPageTitle = getPageTitle;
/**
* Converts YAML object to a YAML string
* @param vars
*/
const toYAML = (vars) => {
const yaml = `---
${Object.entries(vars)
.map(([key, value]) => `${key}: ${typeof value === 'string' ? `"${escapeString(value)}"` : value}`)
.join('\n')}
---`;
return yaml;
};
// prettier-ignore
const escapeString = (str) => str.replace(/([^\\])'/g, '$1\\\'');
let FrontMatterComponent = class FrontMatterComponent extends components_2.RendererComponent {
constructor() {
super(...arguments);
this.globalsFile = 'modules.md';
}
initialize() {
super.initialize();
this.listenTo(this.application.renderer, {
[events_1.PageEvent.END]: this.onPageEnd,
});
}
onPageEnd(page) {
if (page.contents) {
page.contents = exports.prependYAML(page.contents, this.getYamlItems(page));
}
}
getYamlItems(page) {
const pageTitle = this.getTitle(page);
const sidebarLabel = this.getSidebarLabel(page);
let items = {
title: pageTitle,
};
if (sidebarLabel && sidebarLabel !== pageTitle) {
items = { ...items, sidebar_label: sidebarLabel };
}
return {
...items,
custom_edit_url: null,
hide_title: true,
};
}
getSidebarLabel(page) {
if (!this.sidebar) {
return null;
}
if (page.url === this.entryDocument) {
return page.url === page.project.url
? this.sidebar.indexLabel
: this.sidebar.readmeLabel;
}
if (page.url === this.globalsFile) {
return this.sidebar.indexLabel;
}
return this.sidebar.fullNames ? page.model.getFullName() : page.model.name;
}
getId(page) {
return path.basename(page.url, path.extname(page.url));
}
getTitle(page) {
const readmeTitle = this.readmeTitle || page.project.name;
if (page.url === this.entryDocument && page.url !== page.project.url) {
return readmeTitle;
}
return exports.getPageTitle(page);
}
};
__decorate([
typedoc_1.BindOption('out')
], FrontMatterComponent.prototype, "out", void 0);
__decorate([
typedoc_1.BindOption('sidebar')
], FrontMatterComponent.prototype, "sidebar", void 0);
__decorate([
typedoc_1.BindOption('globalsTitle')
], FrontMatterComponent.prototype, "globalsTitle", void 0);
__decorate([
typedoc_1.BindOption('readmeTitle')
], FrontMatterComponent.prototype, "readmeTitle", void 0);
__decorate([
typedoc_1.BindOption('entryDocument')
], FrontMatterComponent.prototype, "entryDocument", void 0);
FrontMatterComponent = __decorate([
components_1.Component({ name: 'front-matter' })
], FrontMatterComponent);
exports.FrontMatterComponent = FrontMatterComponent;

View File

@@ -1,12 +1,17 @@
import * as path from 'path';
// @ts-ignore
import { BindOption } from 'typedoc';
// @ts-ignore
import { Component } from 'typedoc/dist/lib/converter/components';
// @ts-ignore
import { RendererComponent } from 'typedoc/dist/lib/output/components';
// @ts-ignore
import { PageEvent } from 'typedoc/dist/lib/output/events';
import { FrontMatter, Sidebar } from './types';
// @ts-ignore
import { reflectionTitle } from 'typedoc-plugin-markdown/dist/resources/helpers/reflection-title';
export interface FrontMatterVars {
@@ -70,6 +75,7 @@ export class FrontMatterComponent extends RendererComponent {
initialize() {
super.initialize();
// @ts-ignore
this.listenTo(this.application.renderer, {
[PageEvent.END]: this.onPageEnd,
});

1
src/index.d.ts vendored
View File

@@ -1 +0,0 @@
export { default } from './plugin';

View File

@@ -1,5 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = void 0;
var plugin_1 = require("./plugin");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return plugin_1.default; } });

View File

@@ -1 +1,52 @@
export { default } from './plugin';
// const core = require("@actions/core");
const { rmdir } = require("fs").promises;
const path = require("path");
const overrideRequire = require("override-require");
const core = {
getInput: (variable) => process.env[variable],
setFailed: (message) => console.log(message)
};
(async () => {
try {
// Where your docs live, should be the folder containing the crates docs
const originPath = core.getInput("originPath"); // e.g. "/path/to/project/src/";
const sidebarFile = core.getInput("sidebarFile");
// Where you'll save your MD files
const targetPath = core.getInput("targetPath"); // e.g. "/path/to/docusaurus/website/docs/api/js/";
const docusaurusPath = core.getInput("docusaurusPath");
const overrideCondition = (request) => request.startsWith("typedoc");
const resolveRequest = (request) =>
require(path.normalize(
process.cwd().replace("/dist/typedocusaurus", "") + `/${originPath}node_modules/${request}`
));
overrideRequire(overrideCondition, resolveRequest);
const { default: generate } = require("./plugin");
await rmdir(targetPath, { recursive: true });
await generate(docusaurusPath, {
entryPoints: originPath + "src",
out: targetPath,
entryDocument: "index.md",
hideInPageTOC: true,
hideBreadcrumbs: true,
watch: false,
tsconfig: originPath + "tsconfig.json",
sidebar: {
sidebarFile,
},
readme: "none",
});
console.log("Tasks completed!");
} catch (error) {
core.setFailed(error.message);
}
})();

12
src/options.d.ts vendored
View File

@@ -1,12 +0,0 @@
import { Application } from 'typedoc';
import { PluginOptions } from './types';
/**
* Merge default with user options
* @param opts
*/
export declare const getOptions: (siteDir: string, opts: Partial<PluginOptions>) => PluginOptions;
/**
* Add docusaurus options to converter
* @param app
*/
export declare const addOptions: (app: Application) => void;

View File

@@ -1,96 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addOptions = exports.getOptions = void 0;
const path = require("path");
const typedoc_1 = require("typedoc");
/**
* Default plugin options
*/
const DEFAULT_PLUGIN_OPTIONS = {
id: 'default',
docsRoot: 'docs',
out: 'api',
entryDocument: 'index.md',
hideInPageTOC: true,
hideBreadcrumbs: true,
sidebar: {
fullNames: false,
sidebarFile: 'typedoc-sidebar.js',
indexLabel: 'Table of contents',
readmeLabel: 'Readme',
sidebarPath: '',
},
plugin: ['none'],
outputDirectory: '',
siteDir: '',
watch: false,
};
/**
* Merge default with user options
* @param opts
*/
const getOptions = (siteDir, opts) => {
// base options
let options = {
...DEFAULT_PLUGIN_OPTIONS,
...opts,
};
// sidebar
if (opts.sidebar === null) {
options = { ...options, sidebar: null };
}
else {
const sidebar = {
...DEFAULT_PLUGIN_OPTIONS.sidebar,
...opts.sidebar,
};
options = {
...options,
sidebar: {
...sidebar,
sidebarPath: path.resolve(siteDir, sidebar.sidebarFile),
},
};
}
// additional
options = {
...options,
siteDir,
outputDirectory: path.resolve(siteDir, options.docsRoot, options.out),
};
return options;
};
exports.getOptions = getOptions;
/**
* Add docusaurus options to converter
* @param app
*/
const addOptions = (app) => {
// configure deault typedoc options
app.options.addReader(new typedoc_1.TypeDocReader());
app.options.addReader(new typedoc_1.TSConfigReader());
// expose plugin options to typedoc so we can access if required
app.options.addDeclaration({
name: 'id',
});
app.options.addDeclaration({
name: 'docsRoot',
});
app.options.addDeclaration({
name: 'siteDir',
});
app.options.addDeclaration({
name: 'outputDirectory',
});
app.options.addDeclaration({
name: 'globalsTitle',
});
app.options.addDeclaration({
name: 'readmeTitle',
});
app.options.addDeclaration({
name: 'sidebar',
type: typedoc_1.ParameterType.Mixed,
});
};
exports.addOptions = addOptions;

View File

@@ -1,12 +1,19 @@
import * as path from 'path';
import {
// @ts-ignore
Application,
// @ts-ignore
MixedDeclarationOption,
// @ts-ignore
ParameterType,
// @ts-ignore
StringDeclarationOption,
// @ts-ignore
TSConfigReader,
// @ts-ignore
TypeDocReader,
// @ts-ignore
} from 'typedoc';
import { PluginOptions, SidebarOptions } from './types';

2
src/plugin.d.ts vendored
View File

@@ -1,2 +0,0 @@
import { PluginOptions } from './types';
export default function generate(siteDir: string, opts: Partial<PluginOptions>): Promise<void>;

View File

@@ -1,38 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const typedoc_1 = require("typedoc");
const MarkdownPlugin = require("typedoc-plugin-markdown");
const front_matter_1 = require("./front-matter");
const options_1 = require("./options");
const render_1 = require("./render");
const sidebar_1 = require("./sidebar");
async function generate(siteDir, opts) {
// we need to generate an empty sidebar up-front so it can be resolved from sidebars.js
const options = options_1.getOptions(siteDir, opts);
// if (options.sidebar) {
// writeSidebar(options.sidebar, 'module.exports=[];');
// }
// initialize and build app
const app = new typedoc_1.Application();
// load the markdown plugin
MarkdownPlugin(app);
// customise render
app.renderer.render = render_1.render;
// add plugin options
options_1.addOptions(app);
// bootstrap typedoc app
app.bootstrap(options);
// add frontmatter component to typedoc renderer
app.renderer.addComponent('fm', new front_matter_1.FrontMatterComponent(app.renderer));
// add sidebar component to typedoc renderer
app.renderer.addComponent('sidebar', new sidebar_1.SidebarComponent(app.renderer));
// return the generated reflections
const project = app.convert();
// if project is undefined typedoc has a problem - error logging will be supplied by typedoc.
if (!project) {
return;
}
// generate or watch app
return app.generateDocs(project, options.outputDirectory);
}
exports.default = generate;

View File

@@ -1,4 +1,6 @@
// @ts-ignore
import { Application } from 'typedoc';
// @ts-ignore
import * as MarkdownPlugin from 'typedoc-plugin-markdown';
import { FrontMatterComponent } from './front-matter';
@@ -34,9 +36,11 @@ export default async function generate(
app.bootstrap(options);
// add frontmatter component to typedoc renderer
// @ts-ignore
app.renderer.addComponent('fm', new FrontMatterComponent(app.renderer));
// add sidebar component to typedoc renderer
// @ts-ignore
app.renderer.addComponent('sidebar', new SidebarComponent(app.renderer));
// return the generated reflections

2
src/render.d.ts vendored
View File

@@ -1,2 +0,0 @@
import { ProjectReflection } from 'typedoc';
export declare function render(project: ProjectReflection, outputDirectory: string): Promise<void>;

View File

@@ -1,25 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.render = void 0;
const events_1 = require("typedoc/dist/lib/output/events");
const ts = require("typescript");
async function render(project, outputDirectory) {
var _a;
if (!this.prepareTheme() || !this.prepareOutputDirectory(outputDirectory)) {
return;
}
const output = new events_1.RendererEvent(events_1.RendererEvent.BEGIN, outputDirectory, project);
output.settings = this.application.options.getRawValues();
output.urls = this.theme.getUrls(project);
this.trigger(output);
if (!output.isDefaultPrevented) {
(_a = output.urls) === null || _a === void 0 ? void 0 : _a.forEach((mapping, i) => {
var _a;
this.renderDocument(output.createPageEvent(mapping));
ts.sys.write(`\rGenerated ${i + 1} of ${(_a = output.urls) === null || _a === void 0 ? void 0 : _a.length} TypeDoc docs`);
});
ts.sys.write(`\n`);
this.trigger(events_1.RendererEvent.END, output);
}
}
exports.render = render;

View File

@@ -1,4 +1,6 @@
// @ts-ignore
import { ProjectReflection, UrlMapping } from 'typedoc';
// @ts-ignore
import { RendererEvent } from 'typedoc/dist/lib/output/events';
import * as ts from 'typescript';

26
src/sidebar.d.ts vendored
View File

@@ -1,26 +0,0 @@
import { RendererComponent } from 'typedoc/dist/lib/output/components';
import { RendererEvent } from 'typedoc/dist/lib/output/events';
import { SidebarItem, SidebarOptions } from './types';
export declare class SidebarComponent extends RendererComponent {
sidebar: SidebarOptions;
siteDir: string;
out: string;
initialize(): void;
onRendererBegin(renderer: RendererEvent): Promise<void>;
/**
* returns a sidebar category node
*/
getSidebarCategory(title: string, items: SidebarItem[]): {
type: string;
label: string;
items: SidebarItem[];
};
/**
* returns the url key for relevant doc
*/
getUrlKey(out: string, url: string): string;
}
/**
* Write content to sidebar file
*/
export declare const writeSidebar: (sidebar: SidebarOptions, content: string) => void;

View File

@@ -1,99 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeSidebar = exports.SidebarComponent = void 0;
const fs = require("fs");
const path = require("path");
const typedoc_1 = require("typedoc");
const components_1 = require("typedoc/dist/lib/converter/components");
const components_2 = require("typedoc/dist/lib/output/components");
const events_1 = require("typedoc/dist/lib/output/events");
const promises_1 = require("fs/promises");
let SidebarComponent = class SidebarComponent extends components_2.RendererComponent {
initialize() {
this.listenTo(this.application.renderer, {
[events_1.RendererEvent.BEGIN]: this.onRendererBegin,
});
}
async onRendererBegin(renderer) {
var _a;
const navigation = (_a = this.application.renderer.theme) === null || _a === void 0 ? void 0 : _a.getNavigation(renderer.project);
const out = this.out.match(/(?:.*)en\/(.*)/)[1];
// map the navigation object to a Docuaurus sidebar format
const sidebarItems = (navigation === null || navigation === void 0 ? void 0 : navigation.children) ? navigation.children.map((navigationItem) => {
if (navigationItem.isLabel) {
const sidebarCategoryItems = navigationItem.children
? navigationItem.children.map((navItem) => {
const url = this.getUrlKey(out, navItem.url);
if (navItem.children && navItem.children.length > 0) {
const sidebarCategoryChildren = navItem.children.map((childGroup) => this.getSidebarCategory(childGroup.title, childGroup.children
? childGroup.children.map((childItem) => this.getUrlKey(out, childItem.url))
: []));
return this.getSidebarCategory(navItem.title, [
url,
...sidebarCategoryChildren,
]);
}
return url;
})
: [];
return this.getSidebarCategory(navigationItem.title, sidebarCategoryItems);
}
return this.getUrlKey(out, navigationItem.url);
})
: [];
const sidebarPath = this.sidebar.sidebarPath;
const sidebarContent = JSON.parse(await promises_1.readFile(sidebarPath, "utf-8"));
const index = sidebarContent.docs[3].items
.map((row, index) => (row.label && row.label === "JavaScript" ? index : 0))
.reduce((accumulator, value) => accumulator + value);
sidebarContent.docs[3].items[index].items = sidebarItems; // Specify where to put the items
promises_1.writeFile(sidebarPath, JSON.stringify(sidebarContent, null, 2));
this.application.logger.success(`TypeDoc sidebar written to ${sidebarPath}`);
}
/**
* returns a sidebar category node
*/
getSidebarCategory(title, items) {
return {
type: 'category',
label: title,
items,
};
}
/**
* returns the url key for relevant doc
*/
getUrlKey(out, url) {
const urlKey = url.replace('.md', '');
return out ? out + '/' + urlKey : urlKey;
}
};
__decorate([
typedoc_1.BindOption('sidebar')
], SidebarComponent.prototype, "sidebar", void 0);
__decorate([
typedoc_1.BindOption('siteDir')
], SidebarComponent.prototype, "siteDir", void 0);
__decorate([
typedoc_1.BindOption('out')
], SidebarComponent.prototype, "out", void 0);
SidebarComponent = __decorate([
components_1.Component({ name: 'sidebar' })
], SidebarComponent);
exports.SidebarComponent = SidebarComponent;
/**
* Write content to sidebar file
*/
const writeSidebar = (sidebar, content) => {
if (!fs.existsSync(path.dirname(sidebar.sidebarPath))) {
fs.mkdirSync(path.dirname(sidebar.sidebarPath));
}
fs.writeFileSync(sidebar.sidebarPath, content);
};
exports.writeSidebar = writeSidebar;

View File

@@ -1,9 +1,12 @@
import * as fs from 'fs';
import * as path from 'path';
// @ts-ignore
import { BindOption } from 'typedoc';
// @ts-ignore
import { Component } from 'typedoc/dist/lib/converter/components';
// @ts-ignore
import { RendererComponent } from 'typedoc/dist/lib/output/components';
// @ts-ignore
import { RendererEvent } from 'typedoc/dist/lib/output/events';
import { SidebarItem, SidebarOptions } from './types';
@@ -19,12 +22,14 @@ export class SidebarComponent extends RendererComponent {
out!: string;
initialize() {
// @ts-ignore
this.listenTo(this.application.renderer, {
[RendererEvent.BEGIN]: this.onRendererBegin,
});
}
async onRendererBegin(renderer: RendererEvent) {
// @ts-ignore
const navigation = this.application.renderer.theme?.getNavigation(
renderer.project,
);
@@ -76,6 +81,7 @@ export class SidebarComponent extends RendererComponent {
sidebarContent.docs[3].items[index].items = sidebarItems; // Specify where to put the items
writeFile(sidebarPath, JSON.stringify(sidebarContent, null, 2));
// @ts-ignore
this.application.logger.success(
`TypeDoc sidebar written to ${sidebarPath}`,
);

41
src/types.d.ts vendored
View File

@@ -1,41 +0,0 @@
export interface PluginOptions {
id: string;
docsRoot: string;
out: string;
sidebar: SidebarOptions | null;
readmeTitle?: string;
globalsTitle?: string;
plugin: string[];
readme?: string;
disableOutputCheck?: boolean;
entryPoints?: string[];
entryDocument: string;
hideInPageTOC: boolean;
hideBreadcrumbs: boolean;
siteDir: string;
outputDirectory: string;
watch: boolean;
}
export interface FrontMatter {
id?: string;
title: string;
slug?: string;
sidebar_label?: string;
hide_title?: boolean;
}
export interface SidebarOptions {
fullNames?: boolean;
sidebarFile: string;
sidebarPath: string;
indexLabel?: string;
readmeLabel?: string;
}
export interface Sidebar {
[sidebarId: string]: SidebarItem[];
}
export interface SidebarCategory {
type: string;
label: string;
items: SidebarItem[];
}
export declare type SidebarItem = SidebarCategory | string;

View File

@@ -1,2 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

6
src/watch.d.ts vendored
View File

@@ -1,6 +0,0 @@
import { Application } from 'typedoc';
import { PluginOptions } from './types';
/**
* Calls TypeDoc's `convertAndWatch` and force trigger sidebars refresh.
*/
export declare const convertAndWatch: (app: Application, options: PluginOptions) => void;

View File

@@ -1,22 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertAndWatch = void 0;
const fs = require("fs");
const path = require("path");
/**
* Calls TypeDoc's `convertAndWatch` and force trigger sidebars refresh.
*/
const convertAndWatch = (app, options) => {
const sidebarsJsPath = path.resolve(options.siteDir, 'sidebars.js');
app.convertAndWatch(async (project) => {
if (options.sidebar) {
// remove typedoc sidebar from require cache
delete require.cache[options.sidebar.sidebarPath];
// force trigger a sidebars.js refresh
const sidebarJsContent = fs.readFileSync(sidebarsJsPath);
fs.writeFileSync(sidebarsJsPath, sidebarJsContent);
}
await app.generateDocs(project, options.outputDirectory);
});
};
exports.convertAndWatch = convertAndWatch;

View File

@@ -1,6 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
// @ts-ignore
import { Application } from 'typedoc';
import { PluginOptions } from './types';

View File

@@ -1,6 +1,6 @@
{
"compilerOptions": {
"declaration": true,
"declaration": false,
"experimentalDecorators": true,
"lib": ["es2018", "dom"],
"module": "commonjs",
@@ -10,6 +10,7 @@
"removeComments": false,
"sourceMap": false,
"strictNullChecks": true,
"target": "es2018"
"target": "es2018",
"outDir": "dist"
}
}

288
yarn.lock
View File

@@ -12,294 +12,22 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.35.tgz#42c953a4e2b18ab931f72477e7012172f4ffa313"
integrity sha512-Lt+wj8NVPx0zUmUwumiVXapmaLUcAk3yPuHCFVXras9k5VT9TdhJqKqGVUQCD60OTMCl0qxJ57OiTL0Mic3Iag==
"@zeit/ncc@^0.22.3":
"@zeit/ncc@^0.27.0":
version "0.22.3"
resolved "https://registry.yarnpkg.com/@zeit/ncc/-/ncc-0.22.3.tgz#fca6b86b4454ce7a7e1e7e755165ec06457f16cd"
integrity sha512-jnCLpLXWuw/PAiJiVbLjA8WBC0IJQbFeUwF4I9M+23MvIxTxk5pD4Q8byQBSPmHQjz5aBoA7AKAElQxMpjrCLQ==
at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
colors@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78"
integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
fs-extra@^9.1.0:
version "9.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==
dependencies:
at-least-node "^1.0.0"
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^2.0.0"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
function-bind@^1.1.1:
override-require@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==
resolved "https://registry.yarnpkg.com/override-require/-/override-require-1.1.1.tgz#6ae22fadeb1f850ffb0cf4c20ff7b87e5eb650df"
integrity sha1-auIvresfhQ/7DPTCD/e4fl62UN8=
glob@^7.0.0:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
version "4.2.6"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee"
integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==
handlebars@^4.7.6, handlebars@^4.7.7:
version "4.7.7"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1"
integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==
dependencies:
minimist "^1.2.5"
neo-async "^2.6.0"
source-map "^0.6.1"
wordwrap "^1.0.0"
optionalDependencies:
uglify-js "^3.1.4"
has@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796"
integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==
dependencies:
function-bind "^1.1.1"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
interpret@^1.0.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e"
integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==
is-core-module@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a"
integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==
dependencies:
has "^1.0.3"
jsonfile@^6.0.1:
version "6.1.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
dependencies:
universalify "^2.0.0"
optionalDependencies:
graceful-fs "^4.1.6"
lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
lru-cache@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==
dependencies:
yallist "^3.0.2"
lunr@^2.3.9:
version "2.3.9"
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1"
integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==
marked@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/marked/-/marked-2.0.1.tgz#5e7ed7009bfa5c95182e4eb696f85e948cefcee3"
integrity sha512-5+/fKgMv2hARmMW7DOpykr2iLhl0NgjyELk5yn92iE7z8Se1IS9n3UsFm86hFXIkvMBmVxki8+ckcpjBeyo/hw==
minimatch@^3.0.0, minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
dependencies:
brace-expansion "^1.1.7"
minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
neo-async@^2.6.0:
version "2.6.2"
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"
onigasm@^2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/onigasm/-/onigasm-2.2.5.tgz#cc4d2a79a0fa0b64caec1f4c7ea367585a676892"
integrity sha512-F+th54mPc0l1lp1ZcFMyL/jTs2Tlq4SqIHKIXGZOR/VkHkF9A7Fr5rRr5+ZG/lWeRsyrClLYRq7s/yFQ/XhWCA==
dependencies:
lru-cache "^5.1.1"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
path-parse@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
progress@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==
rechoir@^0.6.2:
version "0.6.2"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384"
integrity sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=
dependencies:
resolve "^1.1.6"
resolve@^1.1.6:
version "1.20.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975"
integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==
dependencies:
is-core-module "^2.2.0"
path-parse "^1.0.6"
shelljs@^0.8.4:
version "0.8.4"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2"
integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
rechoir "^0.6.2"
shiki@^0.9.2:
version "0.9.2"
resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.9.2.tgz#b9e660b750d38923275765c4dc4c92b23877b115"
integrity sha512-BjUCxVbxMnvjs8jC4b+BQ808vwjJ9Q8NtLqPwXShZ307HdXiDFYP968ORSVfaTNNSWYDBYdMnVKJ0fYNsoZUBA==
dependencies:
onigasm "^2.2.5"
vscode-textmate "^5.2.0"
source-map@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
typedoc-default-themes@^0.12.8:
version "0.12.8"
resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.12.8.tgz#a04dfc4c01545bc52d2ee6c6ed98a381f2b7249f"
integrity sha512-tyjyDTKy/JLnBSwvhoqd99VIjrP33SdOtwcMD32b+OqnrjZWe8HmZECbfBoacqoxjHd58gfeNw6wA7uvqWFa4w==
typedoc-plugin-markdown@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.6.0.tgz#08067aeb69a6b5e16c0eda72cceaa99cf91ff245"
integrity sha512-fg4xby3awJVVxB8TdhHNsZQfiTC5x1XmauVwhKXc6hGeu1bzTnqrkmDT8NCjxfUgw64si8cUX1jBfBjAHthWpQ==
dependencies:
handlebars "^4.7.6"
typedoc@^0.20.30:
version "0.20.30"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.20.30.tgz#a7e0e3902c08df9b3f9d66da0cc603eed716fad3"
integrity sha512-A4L6JDShPFwZDt9qp7FBsEpW7C6rA5fRv6ywgBuxGxZnT2wuF5afbWzmrwqHR3Xw38V1H2L4v/VJ0S/llBwV6Q==
dependencies:
colors "^1.4.0"
fs-extra "^9.1.0"
handlebars "^4.7.7"
lodash "^4.17.21"
lunr "^2.3.9"
marked "^2.0.1"
minimatch "^3.0.0"
progress "^2.0.3"
shelljs "^0.8.4"
shiki "^0.9.2"
typedoc-default-themes "^0.12.8"
tslib@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"
integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==
typescript@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3"
integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw==
uglify-js@^3.1.4:
version "3.13.0"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.13.0.tgz#66ed69f7241f33f13531d3d51d5bcebf00df7f69"
integrity sha512-TWYSWa9T2pPN4DIJYbU9oAjQx+5qdV5RUDxwARg8fmJZrD/V27Zj0JngW5xg1DFz42G0uDYl2XhzF6alSzD62w==
universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
vscode-textmate@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-5.2.0.tgz#01f01760a391e8222fe4f33fbccbd1ad71aed74e"
integrity sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==
wordwrap@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
yallist@^3.0.2:
version "3.1.1"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"
integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==