vuepress-plugin-typedoc
Version:
A VuePress plugin to build api documentation with TypeDoc.
70 lines (69 loc) • 2.2 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.addOptions = exports.getOptions = void 0;
const path = __importStar(require("path"));
const typedoc_1 = require("typedoc");
const DEFAULT_PLUGIN_OPTIONS = {
out: 'api',
sidebar: {
parentCategory: 'API',
fullNames: false,
sidebarFile: 'typedoc-sidebar.js',
sidebarPath: '',
},
plugin: ['none'],
watch: false,
hideBreadcrumbs: true,
};
const getOptions = (opts) => {
let options = {
...DEFAULT_PLUGIN_OPTIONS,
...opts,
};
if (opts.sidebar === null) {
options = { ...options, sidebar: null };
}
else {
const sidebar = {
...DEFAULT_PLUGIN_OPTIONS.sidebar,
...opts.sidebar,
};
options = {
...options,
sidebar: {
...sidebar,
sidebarPath: path.resolve(sidebar.sidebarFile),
},
};
}
return options;
};
exports.getOptions = getOptions;
const addOptions = (app) => {
app.options.addReader(new typedoc_1.TypeDocReader());
app.options.addReader(new typedoc_1.TSConfigReader());
app.options.addDeclaration({
name: 'sidebar',
type: typedoc_1.ParameterType.Mixed,
});
};
exports.addOptions = addOptions;