Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Generate files from a RAML document and Handlebars templates

License

Notifications You must be signed in to change notification settings

mulesoft-labs/raml-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c0df4af · Feb 12, 2022

History

53 Commits
Apr 17, 2018
Apr 17, 2018
Nov 21, 2016
Mar 10, 2015
Mar 22, 2016
Mar 22, 2016
Feb 12, 2022
Mar 10, 2015
Apr 23, 2018
Mar 22, 2016
Mar 22, 2016
Mar 22, 2016
May 14, 2018
Apr 16, 2018
Mar 22, 2016

Repository files navigation

RAML Generator

Greenkeeper badge

NPM version NPM downloads Build status Test coverage

Generate files from a RAML document and templates.

Installation

npm install raml-generator --save

Usage

The module accepts a map of functions (usually compiled templates, such as Handlebars), and returns a function that will generate files given an instance of the RAML 1 parser JSON.

For an example module, take a look at the raml-javascript-generator.

Why use this? It's just a simple, high level API for creating generators with a standard API.

JavaScript Usage

Create the generator function from config. The returned object accepts two arguments, the RAML object and user config.

var fs = require('fs')
var Handlebars = require('handlebars')
var generator = require('raml-generator')

module.exports = generator({
  templates: {
    'index.js': Handlebars.compile(fs.readFileSync(__dirname + '/templates/index.js.hbs', 'utf8'))
  }
}) //=> [Function]

Bin Script

A bin script is provided for you to use with your custom generator. Just require raml-generator/bin and pass in the generator function (from above), package information (package.json) and process.argv.

#!/usr/bin/env node

var bin = require('raml-generator/bin')

var generator = /* The generator function */

bin(generator, require('./package.json'), process.argv)

Generated CLI:

generator --out [directory]

  --data, -d     Path to JSON configuration file
  --include, -i  Include additional RAML files (E.g. extensions)

License

Apache License 2.0