■WheezyでテキストからUML2.0の概要図を作成する。
jre(Java Runtime Environment)なので、chroot環境に導入したが、
通常のWheezy環境にも同じ手順で導入出来る。
Wheezy上にchroot環境のWheezyを構築
http://labunix.hateblo.jp/entry/20130819/1376924059
また、以下の手順のようにchrootにsshアクセス出来るよう構成したのであれば、
「ssh -X」オプションで「plantuml sample.txt -gui」でGUI起動して、
出来た「sample.png」をダブルクリックしてPNGを表示出来る。
CentOS6上にchrootのdebian wheezyを構築
http://labunix.hateblo.jp/entry/20130820/1377007672
■実行環境はWheezyの最新の状態。
$ cat /etc/debian_version
7.2
$ dpkg -l base-files | grep ^ii | awk '{print $3}'
7.1wheezy2
■タイミング図以外は「PlantUML」で概要をSVG出力出来るようだ。
SVGで概要を描いたら、あとはLibreOffice等のGUIで整える方針とする。
シーケンス図
ユースケース図
クラス図
アクティビティ図
コンポーネント図
ステートマシン図
コミュニケーション図(オブジェクト図)
タイミング図
■クラス図と同程度のオブジェクト図も書けるはずだが、
パッケージの説明を読む限りサポートはされていない。
オブジェクト間のメッセージのやりとりを記述するコミュニケーション図にするには、
別途作業が必要。
$ wget http://yar.fruct.org/attachments/download/362/plantuml_7707-1_all.deb
$ dpkg -I plantuml_7707-1_all.deb | tail -8
.
PlantUML supports the following diagram types
- sequence diagram
- use case diagram
- class diagram
- activity diagram
- component diagram
- state diagram
■PlantUMLはJavaとGraphvizに依存するので、先に導入する。
$ dpkg -I plantuml_7707-1_all.deb | grep Depends
Depends: openjdk-6-jre | sun-java5-jre | sun-java6-jre, graphviz
■ここではaptで導入出来る「openjdk-6-jre」を選択。
openjdk-7-jreもあるが、パッケージの要件に従う。
$ apt-cache search "^openjdk-[67]-jre\$"
openjdk-6-jre - OpenJDK Java ランタイム - Hotspot JIT 版
openjdk-7-jre - OpenJDK Java ランタイム - Hotspot JIT 版
$ sudo apt-get install -y openjdk-6-jre graphviz
■PlantUMLで導入されるのはjarファイルとmanマニュアルに、
Xで起動するためのファイル。
$ dpkg -c plantuml_7707-1_all.deb | cut -c 50- | grep -v "/\$"
/usr/bin/plantuml
/usr/share/plantuml/plantuml.jar
/usr/share/doc/plantuml/copyright
/usr/share/doc/plantuml/changelog.Debian.gz
/usr/share/man/man1/plantuml.1.gz
/usr/share/menu/plantuml
■plantumlの導入
$ sudo dpkg -i plantuml_7707-1_all.deb
■オプションを指定しなければPNG形式で出力される。
コマンドのヘルプからはjavaコマンドから呼び出すのが正式の様子だが、
ソースではjavaのパスが通っていればそのまま実行出来るようだ。
$ plantuml -h 2>&1 | grep -i usage
Usage: java -jar plantuml.jar [options] -gui
$ plantuml -h 2>&1 | grep -i svg
-tsvg To generate images using SVG format
-p[ipe] To use stdin for PlantUML source and stdout for PNG/SVG/EPS generation
$ grep -v ^# /usr/bin/plantuml
if [ -n "${JAVA_HOME}" ] && [ -x "${JAVA_HOME}/bin/java" ] ; then
JAVA="${JAVA_HOME}/bin/java"
elif [ -x /usr/bin/java ] ; then
JAVA=/usr/bin/java
else
echo Cannot find JVM
exit 1
fi
$JAVA -jar /usr/share/plantuml/plantuml.jar ${@}
■「Hello World」
$ echo '@startuml
(*) --> "Hello World"
"Hello World" --> (*)
@enduml
' > sample.uml
$ plantuml -tsvg sample.uml
$ gthumb sample.svg
Gtk-Message: Failed to load module "canberra-gtk-module"
■chroot環境の場合だけ「Gtk-Message」が出る。
これは過去に「vmplayer」で対処している。
vmplayer起動時の「"canberra-gtk-module"のロード失敗」に対処する。
http://labunix.hateblo.jp/entry/20130722/1374422141
$ sudo apt-get install -y libcanberra-gtk-module
$ dpkg -L libcanberra-gtk-module | grep "so\$" | sudo tee /etc/ld.so.conf.d/gtk-2.0.conf
/usr/lib/x86_64-linux-gnu/gtk-2.0/modules/libcanberra-gtk-module.so
■余談
概要の概要程度の簡単な図なら、python-*diagの方が簡単に作成出来ると思う。
記述方法がblockdiagやnwdiagに近いというメリットがある。
アクティビティ図とシーケンス図はsphinxにもそのまま使えるパッケージがあるので、
SVG出力も出来るし、sphinxのpluginなので、連携するならちょうど良いかも知れない。
(私はSphinxを使っていないw。。。)
$ apt-cache search "^python-[a-z]*diag"
python-actdiag - generate activity-diagram image file from spec-text file
python-blockdiag - generate block-diagram image file from spec-text file
python-nwdiag - generate network-diagram image file from spec-text file
python-seqdiag - seqdiag generate sequence-diagram image file from spec-text fil
$ apt-cache search "^python-[a-z]*diag" | awk '{print $1}' | \
sudo apt-get install -y `xargs`
$ dpkg -L python-{act,seq}diag | grep README
/usr/share/doc/python-actdiag/README.txt
/usr/share/doc/python-seqdiag/README.txt.gz
$ lv -s /usr/share/doc/python-actdiag/README.txt | grep -A 11 ^simple
simple.diag
------------
simple.diag is simply define nodes and transitions by dot-like text format::
diagram {
A -> B -> C;
lane you {
A; B;
}
lane me {
C;
}
}
$ lv -s /usr/share/doc/python-seqdiag/README.txt.gz | grep -A 11 ^simple
simple.diag
------------
simple.diag is simply define nodes and transitions by dot-like text format::
diagram {
browser -> webserver [label = "GET /index.html"];
browser <-- webserver;
browser -> webserver [label = "POST /blog/comment"];
webserver -> database [label = "INSERT comment"];
webserver <-- database;
browser <-- webserver;
}