0.1.2 • Published 2 years ago

b5g v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
2 years ago

CI Coverage Status npm version

B5G

Bve5 の構文定義ファイルを Mustache のテンプレートファイルに食わせてドキュメントを生成するオレオレ npm パッケージです。 OpenAPI みたいに YAML 定義から様々な定義を自動生成したかったので。

Installation

npm install -g b5g

Usage

CLI

b5g --help

Usage: b5g [options] [command]

generate artifact documents with embedded BveTranSim syntax definitions from template file.

Options:
  -h, --help                               display help for command

Commands:
  render [options] <source> [destination]  render to the template file.
  generate [options] [destination]         generate MapData.
  help [command]                           display help for command

Rendering a template file

b5g render ./template.mst ./rendered.txt

Generate custom syntax definition

b5g generate -d ./definition.yml ./syntaxdefinition.json

Program

import { render, getDefaultMapData } from 'b5g'
import fs from 'fs'

getDefaultMapData()
    .then((map) => {
        fs.readFileSync('./templatefile.mst', 'utf-8')
        const rendered = render(template, mapData)
        fs.writeFile('./renderedfile.txt', rendered)
    })
    .catch((err) => console.error(err))

Supported Handlebar helpers

handlebars-helpers

Grammar Documentation & Sample