typedoc-plugin-merge-modules
Version:
Plugin for TypeDoc that merges the content of modules.
35 lines (34 loc) • 1.15 kB
JavaScript
import { getModulesFrom } from "../utils.js";
import { ModuleBundle } from "./module_bundle.js";
/**
* Merger that moves the content of all modules into the project root.
*/
export class ProjectMerger {
/** The project whose modules are merged. */
project;
/** The plugin which is using this merger. */
plugin;
/**
* Creates a new merger instance.
* @param project The project whose modules are merged.
* @param plugin The plugin which is using this merger.
*/
constructor(project, plugin) {
this.project = project;
this.plugin = plugin;
}
/**
* Performs the merging routine.
*/
execute() {
// In monorepo project each project is also a module => Recursively collect all modules
const allModules = getModulesFrom(this.project);
// Create a module bundle for all the modules
const bundle = new ModuleBundle(this.project);
allModules.forEach((module) => {
bundle.add(module);
});
// Merge the bundle into the project
bundle.merge(this.plugin.runsAfterCategorization, this.project);
}
}