Code Monkey home page Code Monkey logo

yuml-diagram's Introduction

yUML diagrammer

Allows the creation of offline UML diagrams based on the yUML Syntax.

NPM Status github Build Status

Example

Features

  • Currently, the following diagram types are supported:
    • Class
    • Activity
    • Use-case
    • State
    • Deployment
    • Package
    • Sequence
  • Additional directives for altering diagram type and orientation
  • Embedded rendering engine: No need to call an external web service

yUML syntax

Please refer to the wiki page

Installation

This library is published as a npm package here. For installing use:

npm install yuml-diagram

Usage example

const yuml_diagram = require('yuml-diagram');

var yuml = new yuml_diagram();
var svgLightBg = yuml.processYumlDocument(yumlText, false);
var svgDarkBg = yuml.processYumlDocument(yumlText, true);

Try a live example with RunKit: https://runkit.com/embed/r21r931hzoqm

Browserified distribution

For using this library in a browser application, include the script at /dist/yuml-diagram.min.js in your project.

The following example shows how to use it:

<html>
    <head>
        <script src="yuml-diagram.min.js"></script>
        <script>
            function loadSvg()
            {
                var yumlText = 
                    `// {type:class}
                    [A]->[B]`;

                // Generate the diagram
                var yuml  = new yuml_diagram();
                var svg = yuml.processYumlDocument(yumlText, false);

                document.body.innerHTML = svg;
            }
        </script>
    </head>
    <body onload="loadSvg();">        
    </body>
</html>

Contributing

For pull requests, please read CONTRIBUTING.md

Have a nice diagram to show? Please send it for publishing here!

Credits

  • Syntax and some examples taken from yuml.me
  • This package embeds a Javascript port of Dot/Graphviz called viz.js
  • The yuml-to-dot translator is loosely based on a Python project called scruffy
  • The new sequence diagram is based on this github fork

yuml-diagram's People

Contributors

aduh95 avatar jaime-olivares avatar kanian avatar visnup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yuml-diagram's Issues

A space bug render text

version 1.2
question: It seems that the second space disappearοΌ›
the text is blow

// {type:class}
[Customer|πŸ”‘ custId;...{bg:#FFF5E6}]
[Customer Certificate|πŸ”‘ certId;...{bg:#FFF5E6}]
[Customer Contact|πŸ”‘ contactManId;...{bg:#FFF5E6}]
[Customer Contact Attribute|πŸ”‘ contactManId;πŸ”‘ attrId;...{bg:#FFF5E6}]
[Customer Attributes|πŸ”‘ custId;πŸ”‘ attrId;...{bg:#FFF5E6}]
[Customer Special Group|πŸ”‘ custSpecialGroupId;...{bg:#FFF5E6}]
[Customer Group|πŸ”‘ custGroupId;...{bg:green}]
[Customer Manager|πŸ”‘ custManagerId;...{bg:#FFF5E6}]
[Customer Contract|πŸ”‘ contractId;...{bg:#FFF5E6}]
[Customer Contract Item|πŸ”‘ contractItemId;...{bg:#FFF5E6}]
[Customer Contract Item Attribute|πŸ”‘ contractItemAttrId;...{bg:#FFF5E6}]
[Customer Social Meidia|πŸ”‘ custSocialNbrId;...{bg:#FFF5E6}]
[Account|πŸ”‘ acctId;...{bg:#FFF5E6}]
[Subscriber|πŸ”‘ subsId;...{bg:#FFF5E6}]
[Customer Document|πŸ”‘ custDocId;...{bg:#FFF5E6}]

[Customer][Customer Certificate]
[Customer]<1-N>[Customer Contact]
[Customer Contact]<1-N>[Customer Contact Attribute]
[Customer]<1-N>[Customer Attributes]
[Customer]<1-N>[Customer Special Group]
[Customer]<1-N>[Customer Group]
[Customer]<1-N>[Customer Manager]
[Customer]<1-N>[Customer Contract]
[Customer Contract]<1-N>[Customer Contract Item]
[Customer Contract Item]<1-N>[Customer Contract Item Attribute]
[Customer]<1-N>[Customer Social Meidia]
[Customer]<1-N>[Account]
[Customer]<1-N>[Subscriber]
[Customer]<1-N>[Customer Document]

render
image

Class diagram: abstract class/method in italics

The UML convention/standard is to render abstract classes and methods in italics typeface.
Is this possible in a yuml class diagram, and if so, how do you mark the class/method name as abstract/italics?

Package code example code block in wiki is wrong.

// {type:package}
// {generate:true}
[Elegibility & Benefits]->[Elegibility Search]
[Remittances] -> [Remittance Search]
[Notifications] -> [Notification Search]
[Check Claim Status] -> [Claim Search]
[Submit a Claim Online] -> [Patient Search]
[Physician/Provider Directory]
[Remittance Search] -> [Search]
[Notification Search] -> [Search]
[Claim Search] -> [Search]
[Patient Search] -> [Search]
[Eligibility Search] -> [Search]

Class diagram, fields not rendering....

If I code something like this:

[Node|+fld1: string;+fld2:string;-fld3: number]

I don't get the fields rendered into the svg as part of the class.

yuml.me renders this style of yuml just fine, as does the VS Code plugin. Though the VS Code plugin doesn't seem to set the text colour right when you do this and it breaks the middle fld2 line across two lines.

Make it run in the browser

It would be awesome to make it work in a browser environment. Iβ€˜d love to write a docsify plugin.
I tried browserify but the resulting 8.5MB file is hardly usable.
Cheers, matti

Visual Studio Code extension

I installed this via the Visual Studio code extension and can see it output properly. How do I save the output as an SVG file?

Brackets in class diagrams preview

As reported in jaime-olivares/vscode-yuml#43

There seems to be a problem with in class diagrams preview, the class name was displayed enclosed by braces.
When the class was defined including attributes the braces open before the class name and close after last attribute.

I can see it happens with topDown but not with leftToRight

image

SVG not generating on Mac?

// {generate:true} doesn't appear to be making an svg on Mac.

// Test
// {type:state}
// {generate:true}

(start)[Start]->(Test running)
(Test running)[Pause]->(Paused)
(Test running)[Stop]->(end)
(Log retriveal)[Continue]->(Test running)

VS Code Version 1.23.1
Mac 10.13.4 Hiigh Sierra

I don't see anything in the dev tools console log. Though occasionally a memory leak warning with no other plugins installed:

console.ts:136 [Extension Host] (node:15488) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unhandledRejection listeners added. Use emitter.setMaxListeners() to increase limit

Typically happens when opening or closing the view diagram window.

A space bug.

When i create yuml file to describe my classes, i found out that the first space cannot be show. Between X and Y, that space will change Y to new line, but what i want is to make X and Y in one line. Please fix that. thx.
[ZZZ | X Y; Z;]

Improve extensibility & change `processYumlDocument`

Hi,

Your lib seems very interesting. But I can't find a way to choose where to save files (on node), or where it is added in the page. It would be convinient if there were an API method that returns the SVG generated, without doing anything more (which is more application-dependant).

Switch between documents types is hardcoded. It would be great if it were extensible so that anyone can register processing functions simply.

A proper API documentation, informing about methods signatures would be great too.

So what do you plan to do with the lib ?

ubuntu 18.04 vscode yuml plugin memory leak

(node:5597) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added. Use emitter.setMaxListeners() to increase limit

auto add examples that work

I noted that when you start typing in any yuml file 'type:'... it auto suggests and when choosen it completes with an example.

First of all; that is awesome!

Next: I don't know how to use it, as it replaces only some of the text, so it has:

  • a dangling }
  • a prefix // {type:... and then again // {type:

e.g.:

// {type:// {type:sequence}
[:Computer]sendUnsentEmail>[:Server]
[:Computer]newEmail>[:Server]
[:Server]reponse.>[:Computer]
[:Computer]downloadEmail>[:Server]
[:Computer]deleteOldEmail>[:Server]}

Am I using this wrong?

Error: Extension host terminated unexpectedly

extensionService.ts:165 Extension host terminated unexpectedly. Code:  7  Signal:  null
t._onExtensionHostCrashed @ extensionService.ts:165
extensionHost.ts:236 /Users/cem/.vscode/extensions/jaimeolivares.yuml-3.1.2/node_modules/viz.js/viz.js:25
var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("Module['ENVIRONMENT'] value is not valid. must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="funct

Error: write EPIPE
	at _errnoException (util.js:1024:11)
	at WriteWrap.afterWrite [as oncomplete] (net.js:867:14)

Various output formats

Hello Jaime,
this is a very nice tool. I'm trying to use it for documentation, in parallel with development. the result should then be referenced in markdown.
Would it be possible to generate jpg or png?
Maybe in the form {generate:png;size=120%}
TNX

Background-Color for Class with Attributes

In a class diagram, the following does not render the background color:
[Class|Attribute{bg:green}]
This does:
[Class{bg:green}]
It does work on yuml.me (example), so I expect the syntax is right.

Also, white text on green background is hard to read, are there cases where black on green doesn't work?

Wrong Path to data/rgb.txt in loadColors function (file src/utils/yuml2dot-utils.js)

Hi all,
when debugging yuml-diagram in vscode, I run into a 'file not found error":

Screenshot from 2019-11-28 13-59-19

The call stack leading to the error is the following:

Screenshot from 2019-11-28 13-57-14

yumlExample.js has the following content:
Screenshot from 2019-11-28 14-07-16

To fix that, in the loadColors function, rather than having:

var rgb = fs.readFileSync(__dirname + "/../data/rgb.txt", {encoding:"utf8", flag:"r"}).split('\n');

We should have:

var rgb = fs.readFileSync(__dirname + "/../../data/rgb.txt", {encoding:"utf8", flag:"r"}).split('\n');

I will make a pull request for this.

Regards,

semicolons -> \n in class diagrams

It's not putting in the correct line breaks in the svg.

// {type:class}
// {direction:leftToRight}
// {generate:true}

[Customer|Forename;Surname;Email|Save()]

image

Not support handwrite style

it seems that there is no way to set the appearnce style of the UML,such as the handwriting style called "scruffy"

Direction arrow missing in sequence diagram

After the last update of Visual Studio Code (1.26.1) the arrow heads has gone missing in our sequence diagrams.
[Robot]TaskCompleted>[PickProcess] now just show up as a straight line.

Support name in-between association in class Diagram

Hi, just a small improvement, I would like a feature that enables a name in-between an association in class diagram. For the below example, the text "ProvidedWith" is supposed to be placed in-between the given two cardinalities (1 and 0..*)

image

Partion for acitivity diagram

I am not sure if the current version supports partition for the activity diagram if it does. what is the syntax?
I mean something like this:
image
Thank you

Class diagram entity's methods causing entity's class not to render

I'm attempting to process the class diagram provided in the wiki's examples that has the following line:

[Order]*-*>[Product|EAN_Code|promo_price()]

What's happening is the Product class is rendered as "A5," which seems to be caused by the presence of a method inside the class:

Screen Shot 2021-03-31 at 10 39 16 AM

I'm not sure if it is due to the version of node I'm running. Thoughts?

Add zoom in/out of the diagram

I have some rather large diagrams, but can't read them because the text ends up so small. It would be great to be able to zoom in/out, pan, etc.

NPM module not finding rgb.txt file!

Found an issue using the npm module where it won't parse {bg:colour} directives, since it can't find the rgb.txt file. This causes an exception to be thrown, but it's caught and all you see is an "Error parsing the yUML file" error as output in the svg.

In src/util/yuml2dot-utils, the following line

var rgb = fs.readFileSync(__dirname + "/../data/rgb.txt", {encoding:"utf8", flag:"r"}).split('\n');

should read:

var rgb = fs.readFileSync(__dirname + "/../../data/rgb.txt", {encoding:"utf8", flag:"r"}).split('\n');

since the data directory is two levels up from where yuml2dot-utils is located.

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.