Code Monkey home page Code Monkey logo

dgen's Introduction

Turn data into generated code and text files.


dgen takes a template file, plus some data or executable code, and then generates a new file from it.

It simplifies going from structured data to code โ€“ and can be used to generate and format TypeScript, HTML, Markdown, JSON, blog posts, or any other type of text file.

This can be used as a command line utility, or as a module in your own codebase via its exported codegen function.

Examples

Generate Markdown, Typescript, and much more. Check out the full examples.

Setup

Install Deno and ensure it is in your path.

Then, run: deno install -frA --name=dgen https://deno.land/x/dgen/mod.ts

This will install dgen as a command line utility.

Usage

A template is required, and ideally a data file or some TypeScript code to return data.

Templates must be vento (.vto) files.

# Use with input file, data, and output.
dgen --in=myCodegenTemplate.vto --data=myCodegenData.json --out=myCodegenFile.ts

# Use with input file, data, output, plus additional processor step.
dgen --in=myCodegenTemplate.vto --data=myCodegenData.json --processor=myTransformationStep.ts --out=myCodegenFile.ts

Command Line Arguments

Option Description Example Usage
--in Path to the template file (vento .vto template), required --in <template.vto>
--out Path to the output file, optional, will print to stdout if not provided --out <output.ts>
--data Path to the data file (JSON or JSONC), optional --data <data.json>
--processor Path to the JS/TS processor file, optional --processor <processor.ts>
--flags Additional flags to run alongside the codegen process, optional. Accepts 'fmt', 'check', 'print_info'. Set to 'none' to skip defaults. --flags fmt,check,print_info
--help Print the help message --help

dgen's People

Contributors

mattvr avatar

Stargazers

Joe Dakroub avatar oven avatar Ivan avatar Anthony Williams avatar Eryk Miszczuk avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.