@twg2/ts-twg-ast-codegen
v0.31.0
Published
TypeScript code generator utils
Downloads
1,236
Readme
TypeScript TWG AST Code Generator
Dependencies:
- none
TypeScript type transformers and code generator tools for type safe transformation of data structures to code.
This library is designed to integrate with TWG ASTs generated by jparse-code.
See the test/
directory for example usage of the functions in this project.
API Overview
This library is designed to integrate with TWG ASTs generated by jparse-code.
The base CodeAst interfaces found in [code-types/ast-types.d.ts] match the JSON output from jparse-code
.
You can load data types/models manually via the TypeTemplate
interface in code-types/model-types.d.ts and use code-types/TypeConverter
which has methods like parseTypeTemplate()
and TypeScript.parseAndConvertTypeTemplate()
to convert the TypeTemplate
to a CodeAst.Type
.
Or load JSON output directly from jparse-code
and cast it to one of the CodeAst.*
types.
Once you have CodeAst data, you can manipulate it with the help of classes like code-types/ExtractAst.ts or code-types/TypeConverter.ts.
Finally, output the data back to JSON with JSON.stringify()
(since the CodeAst interfaces are designed for JSON parsing/stringifying) or transform the data types/models to source code strings using the classes found in generators/
.
code-types/
Definition files for TWG AST types (generated by jparse-code)
Definitions for the Open API Spec openapi.d.ts
Extractors and converters for creating TWG AST models from templates, see DtoPropertyConverter
and ExtractAst
Converter for Open API specs to TWG AST models, see OpenApiConverter
generators/
Source code generators for code-types
models.
strings/
StringArray for simple multi-line string building. StringCase for checking if a string's casing matchings a particular programming convention such as camelCase, TitleCase, or Under_Score_Case. DefaultPrettyPrinter for manually tracking source code indentation.