UNPKG

macoolka-type-model

Version:

`macoolka-type-model` is a library for define model in TypeScript. It easily build a type contain field and method to your Application. It provide a generation model for type and validition

80 lines (79 loc) 1.74 kB
import { MDocumentable } from '../models/Module'; /** * The define a block node * @desczh * 定义一个代码块 * @since 0.2.0 */ export interface NodeGroup { /** * Block begin content * @desczh * 开始内容 */ begin: string; /** * Block end content * @desczh * 结束内容 */ end: string; /** * indent to root * @desczh * 缩进 */ indent: number; /** * children node content * @desczh * 主体内容 */ content: Array<string>; /** * content's split * @desczh * 主体内容分隔符 */ split?: string; } /** * * @since 0.2.0 */ export interface CodeOption { /** * Get empty string with a indent unit * @desczh * 用缩进单位得到空文本 */ indentMake?: (i: number) => string; /** * Hard line * @desczh * 换行符号 */ line?: string; } /** * The provide a helper about build `block` `line` `item` document. * Block containers head and content and end * Line mean a statement * Item maen a statement and description * @desczh * 提供一些帮助方法在建立`block` `line` `item` * * block包含头尾内容,一般用于interface * line是一条语句 * item是包含注释的语句 * @since 0.2.0 */ export declare const formatCode: ({ indentMake, line }: CodeOption) => { formatLine: (i: number) => (content: string) => string; formatBlock: ({ begin, end, indent, content, split }: NodeGroup) => string; formatItem: (i: number, desc?: boolean) => ({ content, docs: docs }: { content: string; docs: MDocumentable; }) => string; fold: (as: readonly string[]) => string; };