typedoc-plugin-merge-modules
Version:
Plugin for TypeDoc that merges the content of modules.
58 lines (57 loc) • 2.07 kB
JavaScript
import { ParameterType } from "typedoc";
/**
* Class storing the options of the plugin.
*/
export class PluginOptions {
/** Defines if the plugin should rename default exports to their original name. */
_renameDefaults = true;
/** Defines how the plugin should merge modules. */
_mode = "project";
/**
* Returns if the plugin should rename default exports to their original name.
* @returns True, if the plugin should rename default exports to their original name, otherwise false.
*/
get renameDefaults() {
return this._renameDefaults;
}
/**
* Returns how the plugin should merge modules.
* @returns How the plugin should merge modules.
*/
get mode() {
return this._mode;
}
/**
* Adds the command line options of the plugin to the TypeDoc application.
* @param typedoc The TypeDoc application.
*/
// eslint-disable-next-line class-methods-use-this
addToApplication(typedoc) {
typedoc.options.addDeclaration({
type: ParameterType.Boolean,
name: "mergeModulesRenameDefaults",
help: "If true default exports are renamed to their original name as their module is merged.",
defaultValue: true,
});
typedoc.options.addDeclaration({
type: ParameterType.Map,
map: new Map([
["project", "project"],
["module", "module"],
["module-category", "module-category"],
["off", "off"],
]),
name: "mergeModulesMergeMode",
help: "Defines how the plugin should merge modules.",
defaultValue: "project",
});
}
/**
* Reads the values of the plugin options from the application options.
* @param typedoc The TypeDoc application.
*/
readValuesFromApplication(typedoc) {
this._renameDefaults = typedoc.options.getValue("mergeModulesRenameDefaults");
this._mode = typedoc.options.getValue("mergeModulesMergeMode");
}
}