All Projects → prantlf → nomnoml-cli

prantlf / nomnoml-cli

Licence: MIT License
Generates images from nomnoml diagram sources in a NodeJS module or on the command line

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nomnoml-cli

Nomnoml
Sassy 'UML' Diagrams for R
Stars: ✭ 173 (+765%)
Mutual labels:  uml, diagrams
Nomnoml
The sassy UML diagram renderer
Stars: ✭ 1,685 (+8325%)
Mutual labels:  uml, nomnoml
Kroki
Creates diagrams from textual descriptions!
Stars: ✭ 774 (+3770%)
Mutual labels:  uml, diagrams
Umldoclet
Automatically generate PlantUML diagrams in javadoc
Stars: ✭ 138 (+590%)
Mutual labels:  generator, uml
hexo-generator-index2
Filtered index generator for Hexo
Stars: ✭ 40 (+100%)
Mutual labels:  generator
TI-Analysis
关于中国市场培训机构运作流程及运营模式分析论文
Stars: ✭ 42 (+110%)
Mutual labels:  uml
wodle
Static site generator using next and tachyons
Stars: ✭ 29 (+45%)
Mutual labels:  generator
Border-Radius-Generator
A CSS3 Border Radius Generator; Get the best border-radius playground, with a minimalist design!
Stars: ✭ 19 (-5%)
Mutual labels:  generator
iteration utilities
Utilities based on Pythons iterators and generators.
Stars: ✭ 65 (+225%)
Mutual labels:  generator
yed-uml
Examples of various types of UML diagrams created using yEd graph editor
Stars: ✭ 22 (+10%)
Mutual labels:  uml
Jacob
A lightweight library to provide coroutines in Java
Stars: ✭ 14 (-30%)
Mutual labels:  generator
git-conventional-commits
Git Conventional Commits Util to generate Semantic Version and Markdown Change Log and Validate Commit Messag
Stars: ✭ 58 (+190%)
Mutual labels:  generator
badaso
The API & platform builder, build your apps 10x faster even more, it's open source & 100% free !
Stars: ✭ 650 (+3150%)
Mutual labels:  generator
generator-vue-component
📦 Yeoman generator to build your own Vue.js components
Stars: ✭ 32 (+60%)
Mutual labels:  generator
maze-generator
A real-time JavaScript maze generator using the depth-first search algorithm
Stars: ✭ 13 (-35%)
Mutual labels:  generator
express-mvc-generator
Express' Model View Controller Application Generator.
Stars: ✭ 46 (+130%)
Mutual labels:  generator
faker
Faker is a Nim package that generates fake data for you.
Stars: ✭ 28 (+40%)
Mutual labels:  generator
qm
QM model-based design tool and code generator based on UML state machines
Stars: ✭ 54 (+170%)
Mutual labels:  uml
mybatis-generator-plus
轻度扩展mybatis-generator-core插件,与官方插件兼容。
Stars: ✭ 62 (+210%)
Mutual labels:  generator
ts-lehre
Generate document block(JsDoc, EsDoc, TsDoc) from source code
Stars: ✭ 14 (-30%)
Mutual labels:  generator

nomnoml-cli

Latest version Dependency status codecov Code Climate

Generates images from nomnoml diagram sources on the command line and provides a library for a programmatic usage from NodeJS modules

Getting Started

Make sure that you have NodeJS >= 12 installed.

  1. Install pre-requisites of the node-canvas module depending on your operating system

  2. Install the command-line tool and generate a testing image:

npm install -g nomnoml-cli
echo '[nomnoml]is->[awesome]' | nomnoml > awesome.png

Read the documentation about the nomnoml source format

Command-Line Usage

The nomnoml script generates a png, jpg, svg or pdf image from the nomnoml source text. Both file names and standard input and output are supported as parameters. If generating the image fails, exit code 1 is returned to the caller.

$ nomnoml --help

  Usage: nomnoml [option]

  Options:

    -h, --help             output usage information
    -V, --version          output the version number
    -i, --input <path>     file with nomnoml source to read from
    -o, --output <path>    file for the image output to write to
    -f, --format <format>  output format (png, jpg, svg, pdf)
    -w, --width <pixels>   width of the canvas to draw on
    -H, --height <pixels>  height of the canvas to draw on

  The default output format is png. The default canvas size is 640x480 pixels.
  If the input file is omitted, the source is read from the standard input.
  If the output file is omitted, the image is written to the standard output.

  Examples:

    $ echo '[nomnoml]is->[awesome]' | nomnoml > awesome.png
    $ nomnoml -i source.nomnoml -f svg -o target.svg

Programmatic Usage

The main module exports a function which generates the image:

const generateDiagram = require('nomnoml-cli');
const diagram = await generateDiagram(...);

The function returns a Promise to wait for a success or a failure.

The function expects a nomnoml source text as a string or an options object with the following supported properties:

  • input: source to read the nomnoml text from; either a Stream or a string with the actual nomnoml text
  • inputFile: source file path to read the nomnoml source from
  • output: target to write the image to; either a Stream or a string with the file path (undefined by default)
  • resultType: type of the object to resolve the promise with if the output parameter is not provided ('buffer' or 'stream'; the former is default)
  • format: output image format ('png', 'jpg', 'svg' or 'pdf'; the first is default)
  • width: canvas width in pixels (640 by default)
  • height: canvas height in pixels (480 by default)

Either input or inputFile has to be provided, otherwise the function fails. If output is not provided, the function resolves the promise with a Buffer containing the image. If output is provided, the function returns a promise resolved when the output has been written.

Code Samples

const generateDiagram = require('nomnoml-cli');

// Get Buffer with the image
const buffer = await generateDiagram('[nomnoml]is->[awesome]');

// Convert the standard input to standard output
await generateDiagram({
  input: process.stdin,
  output: process.stdout
});

// Create a PNG file from a nomnoml source file
await generateDiagram({
  inputFile: 'source.nomnoml',
  output: 'target.png'
});

Notes

Contents of other .nomnoml files can be imported to the input file using the #import directive. You can use it for sharing style definitions or parts of diagrams among multiple diagram sources.

#import: /usr/local/share/nomnoml/style.nomnoml
#import: shared/style.nomnoml
#import: ./sub-diagram.nomnoml

If the imported file path is relative and starts with ./ or ../, it will be appended to the path of the "parent" file, which the specified file is being imported to. Otherwise the relative path will be appended to the current (executing) directory.

File import directives are processed recursively. However, a single file can be imported only once. If imported once more, scond and other occurrences will be replaced by an empty string.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2015-2022 Ferdinand Prantl

Licensed under the MIT 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].