<commit_before># json2angular

Generate AngularJS applications based on a JSON application grammar.

## Usage

  json2angular -s [schema]

## Development

`json2angular` is a Node module to generate AngularJS projects based on a JSON specification. The module consumes a JSON file describing the application title and states. Each state is coupled with UI elements, and information about how those UI elements affect the application state.

This module uses two mechanisms for code generation.

  * [Mustache](https://npmjs.org/package/mustache) is used to generate multiline HTML templates (e.g. `index.html`) and Javascript (e.g. `app.js`).
  * [json2html](http://json2html.com) is used to generate HTML fragments from a JSON definition.
  
Though `mustache` is great for generating large templates, it can become cumbersome when generating fragments. `json2html` provides a better solution for AngularJS fragments since:

  * it provides a more readable fragment definition (especially when considering AngularJS's curly-braces syntax)
  * the fragment definition is directly borrowed from the application JSON specification.


## JSON Specification

  * The application name is stored on the root level, and specified by the `name` key
  * States are store in a JSON object. The key represents the state name.
  * Each state must have a `ui` and `elements` key.
  * The `ui` key specifies the HTML fragment to generate
  * The `elements` key specifies child nodes
  * Each child node is a container of UI elements associated with another state<commit_msg>some doc<commit_after># json2angular

Generate AngularJS applications based on a JSON application grammar.

## Usage

A SciSpike application is automatically generated from a `.cdsl` file. The generated files include an `allInOne.js` file containing an application's state matrix and various view descriptions located in subdirectories of `public`. `json2angular` is able to generated a client side application using either mechanism.

### State Matrix Usage

    json2angular -n "Application Name" -s allInOne.js

### Views Usage

    json2angular -n "Application Name" -d scispike-app/public

In each case, the `json2angular` utility creates an intermediary user interface model that is used to generate an [AngularJS](http://angularjs.org/) application. This intermediary UI model is described in [JSON Specification](#JSON Specification)

## Development

`json2angular` is a Node module to generate AngularJS projects based on a JSON specification. The module consumes a JSON file describing the application title and states. Each state is coupled with UI elements, and information about how those UI elements affect the application state.

This module uses two mechanisms for code generation.

  * [Mustache](https://npmjs.org/package/mustache) is used to generate multiline HTML templates (e.g. `index.html`) and Javascript (e.g. `app.js`).
  * [json2html](http://json2html.com) is used to generate HTML fragments from a JSON definition.
  
Though `mustache` is great for generating large templates, it can become cumbersome when generating fragments. `json2html` provides a better solution for AngularJS fragments since:

  * it provides a more readable fragment definition (especially when considering AngularJS's curly-braces syntax)
  * the fragment definition is directly borrowed from the application JSON specification.


## JSON Specification

  * The application name is stored on the root level, and specified by the `name` key
  * States are store in a JSON object. The key represents the state name.
  * Each state must have a `ui` and `elements` key.
  * The `ui` key specifies the HTML fragment to generate
  * The `elements` key specifies child nodes
  * Each child node is a container of UI elements associated with another state
{'fraction_non_alphanumeric': 0.05984251968503937, 'fraction_numerical': 0.003937007874015748, 'mean_word_length': 4.555393586005831, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6140157', 'n_tokens_mistral': 960, 'n_tokens_neox': 896, 'n_words': 503}