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

Commit

Permalink
Merge bf7ff07 into 1117a26
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Dec 20, 2015
2 parents 1117a26 + bf7ff07 commit 1f02de5
Show file tree
Hide file tree
Showing 26 changed files with 407 additions and 1,087 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
node_modules
bower_components
coverage
/node_modules/
/bower_components/
/coverage/
.DS_Store
npm-debug.log
/typings/
/dist/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ notifications:
on_failure: change

node_js:
- "0.12"
- "stable"

after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]

Generate files from a RAML document and Handlebars templates.
Generate files from a RAML document and templates.

## Installation

Expand All @@ -15,36 +15,29 @@ npm install raml-generator --save

## Usage

The module accepts a map of Handlebars templates, partials and helpers, and exports a function that can be used to generate files from a RAML object and user data. For an example module, take a look at the [raml-javascript-generator](https://github.com/mulesoft-labs/raml-javascript-generator).
The module accepts a map of functions (usually compiled templates, such as Handlebars) and helper functions, and returns a function that will generate files given an instance of the RAML 1 parser API.

For an example module, take a look at the [raml-javascript-generator](https://github.com/mulesoft-labs/raml-javascript-generator).

### JavaScript Usage

Create the generator function from an object specification. The returned object accepts two parameters, the RAML object and user package information.

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

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

### Handlebars

Inside the Handlebars templates, the [RAML interface](https://github.com/mulesoft-labs/js-raml-object-interface) is exposed as Handlebars data.

```hbs
var baseUri = {{stringify baseUri}}
```

The user data is automatically provided as the Handlebars compile context.

### 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`.
Expand Down
1 change: 1 addition & 0 deletions bin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/bin'
1 change: 1 addition & 0 deletions bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/bin')
99 changes: 0 additions & 99 deletions bin/index.js

This file was deleted.

25 changes: 0 additions & 25 deletions bower.json

This file was deleted.

8 changes: 8 additions & 0 deletions custom_typings/raml-1-parser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Promise = require('native-or-bluebird')

export interface Options {
rejectOnErrors?: boolean
}

export function loadApi (path: string, extensions?: string[], options?: Options): Promise<any>;
export function loadApiSync (path: string, extensions?: string[], options?: Options): any;
14 changes: 0 additions & 14 deletions lib/context/documentation.js

This file was deleted.

107 changes: 0 additions & 107 deletions lib/context/index.js

This file was deleted.

0 comments on commit 1f02de5

Please sign in to comment.