Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The sassy UML diagram renderer

License

NotificationsYou must be signed in to change notification settings

skanaar/nomnoml

Repository files navigation

Hello, this isnomnoml, a tool for drawing UML diagrams based on a simple syntax. It tries to keep its syntax visually as close as possible to the generated UML diagram without resorting to ASCII drawings.

Created byDaniel Kallin with help from a group ofcontributors.

Library

Thenomnoml javascript library can render diagrams on your web page. The only dependency isgraphre. Install nomnoml using eithernpm or good old script inclusion.

SVG output in NodeJS

npm install nomnoml
varnomnoml=require('nomnoml')varsrc='[nomnoml] is -> [awesome]'console.log(nomnoml.renderSvg(src))

In the SVG output the node name is attached to SVG shapes and<g> containers withdata-name attribute. You can use this to implement interactive diagrams.

document.querySelector('svg').onclick=function(e){console.log(e.target.closest('g[data-name]')?.attributes['data-name'])}

HTML Canvas rendering target

<scriptsrc="//unpkg.com/graphre/dist/graphre.js"></script><scriptsrc="//unpkg.com/nomnoml/dist/nomnoml.js"></script><canvasid="target-canvas"></canvas><script>varcanvas=document.getElementById('target-canvas')varsource='[nomnoml] is -> [awesome]'nomnoml.draw(canvas,source)</script>

Command Line Interface

npx nomnoml exposes the SVG renderer with a command-line interface. This mode also supports the#import: <filename> directive for dividing complex diagrams into multiple files.

npx nomnoml input-file.noml

Web application

Thenomnoml web application is a simple editor with a live preview. It is purely client-side and uses your browser'slocalStorage, so your diagram should be here the next time you visit (but no guarantees).

Example

This is how the Decorator pattern can look in nomnoml syntax:

[<frame>Decorator pattern|  [<abstract>Component||+ operation()]  [Client] depends --> [Component]  [Decorator|- next: Component]  [Decorator] decorates -- [ConcreteComponent]  [Component] <:- [Decorator]  [Component] <:- [ConcreteComponent]]

Association types

-    association->   association<->  association-->  dependency<--> dependency-:>  generalization<:-  generalization--:> implementation<:-- implementation+-   composition+->  compositiono-   aggregationo->  aggregation-o)  ball and socketo<-) ball and socket->o  ball and socket--   note-/-  hidden

Classifier types

[name][<abstract> name][<instance> name][<reference> name][<note> name][<package> name][<frame> name][<database> name][<pipe> name][<start> name][<end> name][<state> name][<choice> name][<sync> name][<input> name][<lollipop> lollipop][<sender> name][<socket> socket][<receiver> name][<transceiver> name][<actor> name][<usecase> name][<label> name][<hidden> name][<table> name| a | 5 || b | 7]

Comments

Comments are supported at the start of a line.

//[commented][not //commented]

Id attribute

Two distinct nodes can have the same display name with the id attribute.

[<actor id=a>User][<actor id=b>User][a] -- [b]

Directives

#import: my-common-styles.nomnoml#arrowSize: 1#bendSize: 0.3#direction: down | right#gutter: 5#edgeMargin: 0#gravity: 1#edges: hard | rounded#background: transparent#fill: #eee8d5; #fdf6e3#fillArrows: false#font: Calibri#fontSize: 12#leading: 1.35#lineWidth: 3#padding: 8#spacing: 40#stroke: #33322E#title: filename#zoom: 1#acyclicer: greedy#ranker: network-simplex | tight-tree | longest-path

Custom classifier styles

A directive that starts with "." define a classifier style. The style is written as a space separated list of modifiers and key/value pairs.

#.box: fill=#8f8 dashed#.blob: visual=ellipse title=bold[<box> GreenBox][<blob> HideousBlob]

Modifiers

dashedempty

Key/value pairs

fill=(any css color)stroke=(any css color)align=centeralign=leftdirection=rightdirection=downvisual=actorvisual=classvisual=databasevisual=ellipsevisual=endvisual=framevisual=hiddenvisual=inputvisual=nonevisual=notevisual=packagevisual=pipevisual=receivervisual=rhombvisual=roundrectvisual=sendervisual=startvisual=tablevisual=transceiver

Style title and text body with a comma separated list of text modifiers

title=left,italic,boldbody=center,italic,bold

Text modifiers

boldcenteritalicleftunderline

Contributing

If you want to contribute to the project, more info is available inCONTRIBUTING.md.


[8]ページ先頭

©2009-2025 Movatter.jp