@docuify/engine
Version:
A flexible, pluggable engine for building and transforming documentation content from source files.
64 lines (61 loc) • 1.91 kB
TypeScript
import { QueryContext } from './query_context.js';
import { BasePlugin } from '../base/basePlugin.js';
import { BaseSource } from '../base/baseSource.js';
import { SourceFile, DocuifyNode } from '../base/types.js';
interface DocuifyEngineConfig {
source: BaseSource;
plugins?: BasePlugin[];
filter?: (file: SourceFile, index?: number) => boolean;
disableContentPreload?: boolean;
}
/**
* 🚂 DocuifyEngine — The central powerhouse of Docuify.
* Connect a source, run through plugins, flatten into gold.
*/
declare class DocuifyEngine {
private config;
private tree;
constructor(config: DocuifyEngineConfig);
private get buildResult();
/**
* Builds the Docuify tree from the source.
* Filters are applied here. Lazy loading is respected.
*/
private treeBuilder;
/**
* Applies plugins to the tree. Plugins may mutate nodes, extract metadata, or summon demons.
*/
applyPlugins(): Promise<DocuifyNode>;
/**
* Returns the current Docuify tree.
* Caution: this may return undefined if `buildTree` hasn’t run.
*/
getTree(): DocuifyNode;
/**
* One-click build: fetches source, builds tree, runs plugins.
* Think of it like `npm run build`, but for trees.
*/
buildTree(): Promise<{
head: {};
tree: DocuifyNode;
foot: {
source: string;
pluginNames: string[];
};
}>;
/**
* Flattens the tree and returns only file nodes.
* Ideal for querying, indexing, or just skipping the forest to find your leaf.
*/
buildFlat(): Promise<{
head: {};
nodes: DocuifyNode[];
foot: {
source: string;
pluginNames: string[];
};
}>;
use(base: BasePlugin | BaseSource): void;
query(): Promise<QueryContext>;
}
export { DocuifyEngine, type DocuifyEngineConfig };