UNPKG

haystack-codegen

Version:

Project Haystack Core code generation tools

48 lines (47 loc) 1.52 kB
import { Node } from './Node'; import { Kind } from 'haystack-core'; /** * Generate the code string from a group of nodes. * * @param out The output to write too. * @param nodes The nodes. * @returns The code. */ export declare function generateNodes(out: (code: string) => void, nodes: Node[]): void; /** * Return the generated code from the node. * * @param node The node to run. * @returns The generated code. */ export declare function generateCodeFromNode(node: Node): string; /** * Return a name that can be used as a type. * * @param def The def name to create a type name from. * @param nameToDefCache A name to def cache. * @returns The type name. */ export declare function makeTypeName(def: string, nameToDefCache: Record<string, string>): string; /** * Capitalize the first character of the string. * * @param str The string to capitalize the first letter of. * @returns A string with the first letter being a capital. */ export declare function capitalizeFirstChar(str: string): string; /** * Convert the haystack kind to the name of the `haystack-core` contructor name. * * @param kind The haystack kind value. * @returns The constructor name. * @throws If the kind is unsupported or invalid. */ export declare function convertKindToCtorName(kind: Kind): string; /** * Write the document comments. * * @param out Used to output the code. * @param doc The documentation to write. */ export declare function writeDocComment(out: (code: string) => void, doc: string): void;