Coder Social home page Coder Social logo

juwen / ebnf2railroad Goto Github PK

View Code? Open in Web Editor NEW

This project forked from matthijsgroen/ebnf2railroad

0.0 1.0 0.0 939 KB

Create beautiful documentation for EBNF

Home Page: https://matthijsgroen.github.io/ebnf2railroad/

License: MIT License

JavaScript 95.72% Shell 0.26% Yacc 4.03%

ebnf2railroad's Introduction

EBNF 2 RailRoad

travis npm code style: prettier publishsize license

A command line tool to create great documentation including railroad diagrams based on the ISO/IEC 14977 specification

Features

  • Creates optimized visual syntax diagrams based on the EBNF syntax
  • Quick navigation using references of used declarations
  • Nice comment markup using markdown
  • Validates if document is complete and has no duplicate declarations
  • Shows pretty printed text syntax in the document
  • Pretty printing of the sourcefile

Installation

npm install -g ebnf2railroad

Usage from command line

Usage: ebnf2railroad [options] <file>

Converts an ISO/IEC 14977 EBNF file to a HTML file with SVG railroad diagrams

Options:
  -V, --version          output the version number
  -q, --quiet            suppress output to STDOUT
  -o, --target [target]  output the file to target destination.
  --no-target            skip writing output HTML
  -t, --title [title]    title to use for HTML document
  --lint                 exit with status code 2 if EBNF document has warnings
  --write-style          rewrites the source document with styled text
  --no-optimizations     does not try to optimize the diagrams
  --no-text-formatting   does not format the output text version (becomes single line)
  -h, --help             output usage information

Examples

To generate HTML documentation of the EBNF file:

ebnf2railroad --title 'My Title' inputfile.ebnf -o outputfile.html

To only verify the EBNF file:

ebnf2railroad --lint inputfile.ebnf --no-target

To prettify the source EBNF file:

ebnf2railroad --write-style inputfile.ebnf --no-target

Online examples

Check the examples folder for an example input file and the generated result page.

  • EBNF ebnf2railroad examples/ebnf.ebnf --title EBNF View online
  • JSON ebnf2railroad examples/json.ebnf --title JSON View online

Usage as module

const { parseEbnf, createDocumentation } = require("ebnf2railroad");

const ebnf = "definition = 'a', other, { other } | item, 'b';";
const ast = parseEbnf(ebnf); // can throw parse error exceptions
const htmlOutput = createDocumentation(ast);

Licence

The code is licensed under MIT (see LICENSE file).

Contributing

Thanks for your interest in contributing! There are many ways to contribute to this project. Get started here

Acknowledgements

ebnf2railroad's People

Contributors

matthijsgroen avatar

Watchers

 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.