今天,公司的一位牛人说,在 doxygen 中借助于mscgen工具支持在生成的文档中嵌入 sequence diagram.
自己在网上搜了一下,大体上知道了怎么用这个工具了。
1. 下载 mscgen 工具
http://www.mcternan.me.uk/mscgen/yum/fedora/15/i386/mscgen-0.20-1.fc15.i686.rpm
yum localinstall /mscgen-0.20-1.fc15.i686.rpm
上面的网址(http://www.mcternan.me.uk/mscgen)还介绍了 mscgen的语法。如下所示:
Graphic | Source Representation | Meaning |
---|---|---|
![]() | -> or <- | Message |
![]() | => or <= | Method or function call |
![]() | >> or << | Method or function return value |
![]() | =>> or <<= | Callback |
![]() | :> or <: | Emphasised Message |
![]() | -x or x- | Lost Message |
![]() | ... | Indicates that some signals may be deliberately omitted from the msc, or that some large period of time may have passed. |
![]() | --- | Used to add comment to a block of signals or indicate some action or state has occurred. |
![]() | ||| | Used to add extra space between rows. |
![]() | x->* or *<-x | Broadcast arcs, where the arc is extended to all but the source entity. Any arc label is centred across the whole chart. |
![]() | box | Box arcs, where the arc is replaced with a box between the selected entities. Any arc label is centred in the box and word wrapped if needed. |
![]() | rbox | Rounded box arcs, where the arc is replaced with a box between the selected entities. Any arc label is centred in the box and word wrapped if needed. |
![]() | abox | Angular box arcs, where the arc is replaced with a box between the selected entities. Any arc label is centred in the box and word wrapped if needed. |
![]() | note | Note box arcs, where the arc is replaced with a box between the selected entities. Any arc label is centred in the box and word wrapped if needed. |
ource Attribute | Meaning |
---|---|
label | A label to place on the message arc, or label to use for an entity. This is reproduced literally above the message arc or in place of the entity name. When used as a message arc label this may also contain parameters or required text. If a /n is encountered, it will be interpreted as a newline, placing text below the arc as well as above it in the normal position, or expanding entity tiles onto more lines. |
URL | When generating the image, colour the label in blue. If generating an image map, create an entry for the label to the specified URL. If the message sequence chart is to be embedded in Doxygen documentation, the URL maybe specified as /ref xxx where xxx is the name of some documented element; in this case a link to the element will automatically be made. |
ID | Adds a superscript identifier to the label. Typically this maybe a number such that specific elements can be identified and referred to in surrounding descriptive text. |
IDURL | Similar to the URL attribute, but links from the ID text rather than the message label. This has the same semantics as the URL attribute, but is only of use if an arc also has an ID. |
arcskip | This offsets the vertical position at which an arc reaches its destination entity. |
linecolour, linecolor | For arcs or entities, set the line to the specified colour. |
textcolour, textcolor | For arcs or entities, set label text to the specified colour. |
textbgcolour, textbgcolor | For arcs or entities, set a colour for the text background block. Sets the fill colour for 'box', 'abox', 'rbox' and 'note' shapes. |
arclinecolour, arclinecolor | Only meaningful on a entity, this sets the default line colour for all arcs that originating from that entity. This can be overridden by linecolour attributes on specific arcs as desired. |
arctextcolour, arctextcolor | Only meaningful on a entity, this sets the default text colour for all arcs that originating from that entity. This can be overridden by textcolour attributes on specific arcs as desired. |
arctextbgcolour, arctextbgcolor | Only meaningful on a entity, this sets the default colour for the text background for all arc oriniationg from that entity. This can be overridden by textbgcolour attributes on specific arcs as desired. |
2. 写一段测试代码如下:
/** Sender class. Can be used to send a command to the server. The receiver will acknowlegde the command by calling Ack(). /msc Sender,Receiver; Sender->Receiver [label="Command()", URL="/ref Receiver::Command()"]; Sender<-Receiver [label="Ack()", URL="/ref Ack()", ID="1"]; /endmsc */ class Sender { public : /** Acknowledgement from server */ void Ack(bool ok); }; /** Receiver class. Can be used to receive and execute commands. After execution of a command, the receiver will send an acknowledgement /msc Receiver,Sender; Receiver<-Sender [label="Command()", URL="/ref Command()"]; Receiver->Sender [label="Ack()", URL="/ref Sender::Ack()", ID="1"]; /endmsc */ class Receiver { public : /** Executable a command on the server */ void Command(int commandId); }; 注意,sequence diagam 部分相应的注释要在 msc block内。 运行 doxgen 后,可以看到确实生成了 sequence diagam:![]()
http://blog.csdn.net/caspiansea/article/details/6571434