All Projects → Enteee → Plantuml Parser

Enteee / Plantuml Parser

Licence: apache-2.0
Parse PlantUML with JavaScript or TypeScript

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Plantuml Parser

Length.js
📏 JavaScript library for length units conversion.
Stars: ✭ 292 (+335.82%)
Mutual labels:  parser, javascript-library
React Json Schema
Configure and build views using JSON schemas mapped to React components
Stars: ✭ 131 (+95.52%)
Mutual labels:  parser, javascript-library
When
A natural language date/time parser with pluggable rules
Stars: ✭ 1,113 (+1561.19%)
Mutual labels:  parser
Cppast.codegen
An extensible library providing C# PInvoke codegen from C/C++ files for .NET
Stars: ✭ 65 (-2.99%)
Mutual labels:  parser
Formula Parser
Parsing and evaluating mathematical formulas given as strings.
Stars: ✭ 62 (-7.46%)
Mutual labels:  parser
Mlua
An interpreter of lua-like language written in C++
Stars: ✭ 61 (-8.96%)
Mutual labels:  parser
Share Selected Text
share selected text on twitter, buffer, and some others. Inspired by medium.com
Stars: ✭ 64 (-4.48%)
Mutual labels:  javascript-library
Fobo
FoBo - A Modular Front-End Toolkit module for Lift
Stars: ✭ 59 (-11.94%)
Mutual labels:  javascript-library
Quickstart
🎯 A micro-form for user-specific installation instructions
Stars: ✭ 66 (-1.49%)
Mutual labels:  javascript-library
Quill Delta Parser
A PHP library to parse and render Quill WYSIWYG Deltas into HTML - Flexibel and extendible for custom elements.
Stars: ✭ 63 (-5.97%)
Mutual labels:  parser
Csvparser
C++ parser for CSV file format
Stars: ✭ 65 (-2.99%)
Mutual labels:  parser
Bibliothecary
📔 Libraries.io Package Manager Manifest Parsers
Stars: ✭ 62 (-7.46%)
Mutual labels:  parser
Cssparser.js
cssparser.js is a parser that generate json from css with matched orders & structures.
Stars: ✭ 61 (-8.96%)
Mutual labels:  parser
Obonet
OBO-formatted ontologies → networkx (Python 3)
Stars: ✭ 64 (-4.48%)
Mutual labels:  parser
Url Highlight
PHP library to parse urls from string input
Stars: ✭ 61 (-8.96%)
Mutual labels:  parser
Parser Javascript
Browser sniffing gone too far — A useragent parser library for JavaScript
Stars: ✭ 66 (-1.49%)
Mutual labels:  parser
String Calc
PHP calculator library for mathematical terms (expressions) passed as strings
Stars: ✭ 60 (-10.45%)
Mutual labels:  parser
Csstree
A tool set for CSS including fast detailed parser, walker, generator and lexer based on W3C specs and browser implementations
Stars: ✭ 1,121 (+1573.13%)
Mutual labels:  parser
Dexbox
A lightweight dex file parsing library
Stars: ✭ 64 (-4.48%)
Mutual labels:  parser
Push.js
The world's most versatile desktop notifications framework 🌎
Stars: ✭ 8,536 (+12640.3%)
Mutual labels:  javascript-library

plantuml-parser npm version Build Status Coverage Status Twitter URL

Parse PlantUML with JavaScript or TypeScript

The aim of this project is to provide a feature-complete, well tested and maintainable Parsing Expression Grammar (PEG) for the PlantUML syntax. The parser is designed to be used as JavaScript library or from the Command Line.

Important: The parser is not yet feature-complete. But we focus on writing a robust implementation which can parse parts of diagrams without knowing the full syntax. This means that the parser probably still parses just about enough to get you started. If not, please contribute ❤️.

Installation

$ npm install --save plantuml-parser

Examples / Fixtures

PlantUML is not a formally defined language - something we would like to change. This means we have to build this parser by reverse engineering from examples. For this reason we keep a large set of PlantUML diagrams (in.plantuml) and the corresponding formatted output (parse[File]-out.<formatter>) in test/fixtures/. We even have diagrams which exposed bugs in the parser or diagrams which contain known broken PlantUML syntax. Please help us expand that collection by contributing your own diagrams. Every diagram counts 🚀.

Usage

const { parse, parseFile, formatters } = require('plantuml-parser');

// Example PlantUML
const data = `
@startuml
  class A
  class B
  A --|> B
@enduml
`;

// parse PlantUML
const result = parse(data);

// Format and print parse result
console.log(
  formatters.default(result)
);
Output

[
  {
    "elements": [
      {
        "name": "A",
        "title": "A",
        "isAbstract": false,
        "members": [],
        "extends_": [],
        "implements_": [],
        "generics": [],
        "stereotypes": []
      },
      {
        "name": "B",
        "title": "B",
        "isAbstract": false,
        "members": [],
        "extends_": [],
        "implements_": [],
        "generics": [],
        "stereotypes": []
      },
      {
        "left": "A",
        "right": "B",
        "leftType": "Unknown",
        "rightType": "Unknown",
        "leftArrowHead": "",
        "rightArrowHead": "|>",
        "leftArrowBody": "-",
        "rightArrowBody": "-",
        "leftCardinality": "",
        "rightCardinality": "",
        "label": "",
        "hidden": false
      }
    ]
  }
]

parse(data, options)

Parse PlantUML in data. Returns the parse result.

  • data: data to parse
  • options: supports all PEG.js parser options. Enable tracing with options.verbose = true. If tracing is enabled, options is also forwarded to the tracer object. See pegjs-backtrace options for a full list of supported tracer options.

parseFile(pattern, options, cb)

Parse all PlantUML diagrams in the files matching pattern. If given, the callback function cb will make this function behave asynchronous.

  • pattern: files to parse, supports globbing, e.g.: **/*.plantuml.
  • options: supports all PEG.js parser options. Enable tracing with options.verbose = true. If tracing is enabled, options is also forwarded to the tracer object. See pegjs-backtrace options for a full list of supported tracer options.
  • cb: (optional) asynchronous callback. Called with: cb(err, result)

formatters: A collection of built-in parse result formatters.

For a detailed description of all the formatters see src/formatters.

Command Line Interface

Installation

# npm install --global plantuml-parser

Usage

Options:
  --version        Show version number                                 [boolean]
  --formatter, -f  formatter to use
                              [choices: "default", "graph"] [default: "default"]
  --input, -i      input file(s) to read, supports globbing
                                                       [string] [default: stdin]
  --output, -o     output file to write               [string] [default: stdout]
  --color, -c      colorful output                    [boolean] [default: false]
  --verbose, -v    1x print verbose output, 2x print parser tracing
                                                            [count] [default: 0]
  --help           Show help                                           [boolean]

Features

  • Diagram Types:
    • [x] Class
    • [x] Component
    • [x] Use Case
    • [ ] Sequence
    • [ ] Activity
    • [ ] State
    • [ ] Object
    • [ ] Deployment
    • [ ] Timing
  • Formatters:
    • [x] JSON
    • [x] Graph
  • Testing, CI/CD:
    • [x] Fixtures for all formatters
    • [x] Code coverage
    • [x] Code formatting
    • [x] Code linting
    • [x] Error case testing
    • [ ] Dependency audit
  • Misc

Test

$ npm test

This will run:

  • unit tests
  • code coverage
  • eslint

Contribute ❤️

Every contribution counts. Please,

When contributing code, always also update the fixtures and run tests.

$ npm run fixtures
$ npm test
$ git commit

For more information see our contribution guidelines.

Related

  • PEG.js: Parser Generator for JavaScript
  • ts-pegjs: Plugin for pegjs to generate TypeScript parsers
  • PlantUML code generator: Provides a command line utility to generate code in various languages given a PlantUML class diagram.

License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].