npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mdgen

v0.9.3

Published

Template-based code generator for model-driven development

Downloads

12

Readme

Model-Driven Generation (mdgen)

A command line tool for template-based code generation from metadata encoded in JSON format based on metadata-json files (.mdj) typically created by StarUML.

Installation

This tool depends on Node.js so you need to install it first. Install globally using npm command so as to use mdgen in any directory.

$ npm install -g mdgen

IMPORTANT

This mdgen uses node-canvas module in order to generate diagram image files (PNG and SVG). If you need to export diagram images, you have to install Cairo first before installing this module (To installing Cairo on various platforms, please refer to https://github.com/Automattic/node-canvas). If you don't need to export images, ignore installation errors from node-canvas.

Features

  • Generate codes using EJS templates.
  • Generate a PDF document from diagrams.

Usage

$ mdgen [command] [options]

Generate codes with EJS template

To generate codes with EJS template, use render command with following options:

  • -m, --model <file> : a model file to load (default model.mdj)
  • -t, --template <file> : template file (default template.ejs)
  • -o, --output <file> : output file (default mdgen-out)
  • -s, --select <selector> : selector expression to select a set of elements (default @Project).

To see the help, type mdgen render -h or mdgen render --help in shell.

Here is an example to generate a set Java source files. Loads model.mdj file and renders all of UML Classes with java-template.ejs template, then save to files of its name and .java file extension in out folder.

$ mdgen render -m model.mdj -t java-template.ejs -o "out/<%=element.name%>.java" -s @UMLClass

Export diagram images (PNG or SVG)

To export diagram images, use image command with following options:

  • -m, --model <file> : a model file to load (default model.mdj)
  • -o, --output <file> : output image file name (default <%=diagram.name%>.png)
  • -f, --format <format>, image format "png" or "svg" (default png)
  • -s, --select <selector> : selector expression to select a set of diagrams (default @Diagram).

To see the help, type mdgen image -h or mdgen image --help in shell.

Here is an example to export diagram images. Loads model.mdj file and export all of diagrams as SVG format in images folder.

$ mdgen image -m model.mdj -o "images/<%=diagram.name%>.svg" -f "svg" -s @Diagram

Generate a PDF document

To generate a PDF document of diagrams, use pdf command with following options:

  • -m, --model <file> : model file to load (default model.mdj)
  • -o, --output <file> : output file (default mdgen-out.pdf)
  • -s, --select <selector> : selector expression to select a set of elements (default @Diagram). This means all diagrams.
  • -z, --size <size> : page size (default A4). Full list of page size can be found here.
  • -l, --layout <layout> : page layout (default landscape). Or use portrait.
  • -n, --showname <yesno> : show diagram name on page top (default yes). Or use no.

Here is an example generating all diagrams in a PDF document.

$ mdgen pdf -m model.mdj -o document.pdf

Generate HTML document

To generate HTML docs, use html command with following options:

  • -m, --model <file> : model file to load (default model.mdj)
  • -o, --output <file> : output folder name (default html-out)
  • -d, --diagram <yesno> : export diagram images (default yes). Or use no.

Here is an example generating HTML docs. `

$ mdgen html -m model.mdj -o html-out