user336639
user336639

Reputation: 228

Generating UML diagrams from textual representation

How can I generate a UML sequence diagram from a file containing a textual representation of my process, with command-line tools in Linux?

Upvotes: 14

Views: 16054

Answers (7)

Salticus
Salticus

Reputation: 403

Although PlantUML is listed in the accepted answer (among many other tools) it merits more attention.

In addition to being easily wrapped into a command line tool, PlantUML also has

  1. excellent documentation (check out the docs for sequence diagrams)
  2. simple and powerful syntax (may compare favorably with UMLGraph)
  3. styleable output
  4. extensive tool integration (Emacs, Sphinx)

However PlantUML comes as a java archive so the following setup may be required:

  1. java
  2. graphviz (not required for sequence diagrams)
  3. a bash wrapper

java and graphviz are available as packages for the major linux distros. PlantUML itself is available for Fedora and Ubuntu.

If your distribution does not provide a package, download a jar file from the main site and wrap as a bash script.

A bash wrapper (as follows) can be stored in a file named plantuml on your path i.e. one of the directories listed by echo $PATH. Don't forget to make it executable with chmod u+x plantuml.

#!/bin/bash
# from the vim syntax plugin README at aklt/plantuml-syntax on github
java -jar $HOME/path/to/plantuml.jar -tsvg $@

Then run plantuml apple.uml berry.uml and plantuml will create apple.svg berry.svg.

Upvotes: 17

Jordi Cabot
Jordi Cabot

Reputation: 8208

There are many (many=more than 10) tools for this.
See a complete list.

Upvotes: 6

Paul Sweatte
Paul Sweatte

Reputation: 24617

Use a script to replace:

  • One space with multiple spaces
  • Commas with column characters, such as |
  • Newline characters with carriage returns plus space indentation
  • Dashes with multiple dashes
  • Greater than and less than characters with column span characters

References

Upvotes: -1

nab
nab

Reputation: 4861

Put the following source into .html file and open it in a browser:

<html>
    <head>
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script>
            $(document).ready(function () {
                $('textarea').each(function () {
                    $(this).hide();
                    var source = $(this).html();
                    $('body').append('<img src="http://yuml.me/diagram/scruffy/class/'
                        + source + '" />');
                });
            });
        </script>
    </head>
    <body>
        <textarea>
            [note: You can stick notes on diagrams too!{bg:cornsilk}],
            [Customer]<>1-orders 0..*>[Order],
            [Order]++*-*>[LineItem],
            [Order]-1>[DeliveryMethod],
            [Order]*-*>[Product],
            [Category]<->[Product],
            [DeliveryMethod]^[National],
            [DeliveryMethod]^[International]
        </textarea>
    </body>
</html>

You should be able to see the sample diagram corresponding to the source within the textarea tag. Correct the source according to the yuml samples to draw your own diagram.

Upvotes: 2

Florian Diesch
Florian Diesch

Reputation: 1025

http://umlet.com/ is another solution

Upvotes: 2

Bert F
Bert F

Reputation: 87503

If your text representation is closely similar to yuml, you might be able to use it to produce images, e.g.

Simple Association

[Customer]->[Billing Address]
<img src="http://yuml.me/diagram/scruffy/class/[Customer]->[Billing Address]"/>
Image of sample UML relationship

Upvotes: 2

jcayzac
jcayzac

Reputation: 1461

Not sure if it's what you want, but UMLGraph can generate sequence diagrams using graphviz and ghostscript...

Upvotes: 2

Related Questions