How ca开发者_如何学JAVAn I generate a UML sequence diagram from a file containing a textual representation of my process, with command-line tools in Linux?
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
- excellent documentation (check out the docs for sequence diagrams)
- simple and powerful syntax (may compare favorably with UMLGraph)
- styleable output
- extensive tool integration (Emacs, Sphinx)
However PlantUML comes as a java archive so the following setup may be required:
- java
- graphviz (not required for sequence diagrams)
- 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.
There are many (many=more than 10) tools for this.
See a complete list.
Not sure if it's what you want, but UMLGraph can generate sequence diagrams using graphviz and ghostscript...
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]"/>
http://umlet.com/ is another solution
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.
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
UML in Awk
Transforming XMI to HTML
UMI SVG Modeller
精彩评论