UNPKG

markugen

Version:

Markdown to HTML/PDF static site generation tool

64 lines (63 loc) 1.78 kB
import Markugen, { MarkugenOptions, OutputLabel } from './markugen'; /** * Abstract base class for all generators */ export default abstract class Generator { /** * Instance of Markugen */ readonly mark: Markugen; /** * The type of the generator */ readonly type: string; /** * The generate start time for recording elapsed time */ protected startTime: [number, number] | undefined; /** * Used internally to prevent multiple async calls to {@link generate} */ protected isActive: boolean; /** * Constructs a new generator with the given Markugen instance and options * @param mark the instance of {@link Markugen} * @param options the common {@link MarkugenOptions} */ constructor(mark: Markugen, options?: MarkugenOptions); /** * Generates the output with the initialized options */ abstract generate(): string | string[] | undefined | Promise<string | string[] | undefined>; /** * Initializes generation */ protected start(): void; /** * Computes the elapsed time and finishes everything */ protected finish(): void; /** * Starts a console group */ group(...args: any[]): void; /** * Ends a console group */ groupEnd(): void; /** * Use in place of console.log so the app can handle coloring * and any cli options that were given */ log(label: OutputLabel | string, ...args: any[]): void; /** * Use in place of console.log so the app can handle coloring * and any cli options that were given */ warning(...args: any[]): void; /** * Outputs the given error message * @param e the error to log */ error(e: Error): void; }