@docuify/engine
Version:
A flexible, pluggable engine for building and transforming documentation content from source files.
29 lines (26 loc) • 952 B
text/typescript
import { DocuifyNode } from './types.mjs';
interface TraversalContext {
parent?: DocuifyNode;
ancestors: DocuifyNode[];
index?: number;
visit(child: DocuifyNode, ctx: TraversalContext): void;
state: Record<string, any>;
}
declare abstract class BasePlugin {
/**
* Runs before the tree traversal starts.
* Can return a new root node or nothing.
*/
abstract name: string;
applyBefore?(root: DocuifyNode, state: Record<string, any>): DocuifyNode | void | Promise<DocuifyNode | void>;
/**
* Runs on every node during traversal.
*/
abstract onVisit(node: DocuifyNode, context: TraversalContext): void | Promise<void>;
/**
* Runs after the tree traversal completes.
* Can return a new root node or nothing.
*/
applyAfter?(root: DocuifyNode, state: Record<string, any>): DocuifyNode | void | Promise<DocuifyNode | void>;
}
export { BasePlugin, type TraversalContext };