LoginSignup
53
53

More than 5 years have passed since last update.

Doxygen+Graphvizで、Objective-Cのクラス図を作る

Last updated at Posted at 2013-03-19
  • brew install doxygen graphviz
  • doxygen -g; edit Doxyfile; doxygen;
  • open html/index.html

OSSなライブラリ、たとえばMGBox2の使い方を調べているときに、クラス図が欲しくなりました。
ソースを追っかけてノートに手書きするのも悪くないのですが、せっかくなのでソースから生成させてみました。

調べたところ doxygengraphvizの組み合わせがよさそうなので、この組み合わせをインストールしてクラス図を含むドキュメントを生成させます。

doxygenとgraphvizのインストール

homebrewを使っていれば、brew install doxygen graphvizでインストール出来ます。

mba% brew install doxygen graphviz
==> Downloading http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.3.1.src.tar.gz
######################################################################## 100.0%
==> ./configure --prefix /usr/local/Cellar/doxygen/1.8.3.1
==> make
==> make MAN1DIR=share/man/man1 install
  /usr/local/Cellar/doxygen/1.8.3.1: 5 files, 11M, built in 2.3 minutes
==> Installing graphviz dependency: libpng
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libpng-1.5.13.mountainlion.bottle.tar.gz

curl: (7) Failed to connect to 2001:1ab0:7e1f:1:230:48ff:fed1:9c0a: No route to host
Error: Download failed: https://downloads.sf.net/project/machomebrew/Bottles/libpng-1.5.13.mountainlion.bottle.tar.gz
mba% brew install libpng          
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libpng-1.5.13.mountainlion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libpng-1.5.13.mountainlion.bottle.tar.gz
  /usr/local/Cellar/libpng/1.5.13: 14 files, 1.0M
mba% brew install doxygen graphviz
Error: doxygen-1.8.3.1 already installed
==> Downloading http://www.graphviz.org/pub/graphviz/stable/SOURCES/graphviz-2.30.1.tar.gz
######################################################################## 100.0%
==> Downloading patches
######################################################################## 100.0%
==> Patching
patching file macosx/graphviz.xcodeproj/project.pbxproj
==> ./configure --prefix=/usr/local/Cellar/graphviz/2.30.1 --without-qt --with-quartz --disable-swig --without-pangocair
==> make install
  /usr/local/Cellar/graphviz/2.30.1: 462 files, 11M, built in 6.5 minutes
mba% 

途中IPv6っぽい所でエラーが出ていますが気にしません。

doxygenの設定ファイルと生成

doxygenでドキュメント生成を行う場合は、doxygenの設定ファイル(Doxyfile)が必要です。これはdoxygen -gで生成できます。生成されたDoxyfileの中の"HAVE_DOT"をYESにすると、クラス図も生成されるようになります。

mba% ls
Categories         MGBlockWrapper.h   MGButton.m         MGLine.m           MGScrollView.h     MGTableBoxStyled.m
Doxyfile           MGBlockWrapper.m   MGLayoutBox.h      MGLineStyled.h     MGScrollView.m     html
Doxyfile.origin    MGBox.h            MGLayoutManager.h  MGLineStyled.m     MGTableBox.h       latex
Doxyfile~          MGBox.m            MGLayoutManager.m  MGMushParser.h     MGTableBox.m
MGBase.h           MGButton.h         MGLine.h           MGMushParser.m     MGTableBoxStyled.h
mba% doxygen -g


Configuration file `Doxyfile' created.

Now edit the configuration file and enter

  doxygen Doxyfile

to generate the documentation for your project

mba% cp Doxyfile Doxyfile.origin
mba% E Doxyfile
mba% diff Doxyfile Doxyfile.origin 
1679c1679
< HAVE_DOT               = YES
---
> HAVE_DOT               = NO
mba% 

あとは`doxygenコマンドでよしなにやってくれます。

open html/index.html

生成されたドキュメント(html/index.html)をブラウザで開いて、"Classes"→"Class Hierarchy"を見ると、クラス図を確認できます。
MGBox2のクラス図!

参考にしたサイト

http://momijiame.tumblr.com/post/23166110981/doxygen-graphviz
http://meme.efcl.info/2011/10/doxygen-graphvizobjective-c.html

53
53
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
53
53