Doxygen and plantuml

翻译 2012年03月27日 15:03:56
Doxygen
You can use Doxygen and PlantUML together to integrate UML diagrams into generated documentation :

Defining aliases
Doxygen does not understand the @startuml and @enduml tags, and will generate errors if you use them in comments. You can surround them by HTML comments to have Doxygen ignore them (see below for an example). However, you can also define Doxygen aliases in your Doxyfile for @startuml and @enduml, so that HTML comments are not necessary:

ALIASES = "startuml=\if DontIgnorePlantUMLCode"
ALIASES += "enduml=\endif"

This will have Doxygen ignore everything in-between @startuml and @enduml unless the token 'DontIgnorePlantUMLCode' is defined, which of course isn't.

You can even go one step further: Doxygen supports arguments in aliases, with the syntax @startuml{some argument}. This means you can generate the \image commands automatically:

ALIASES = "startuml{1}=\image html \1\n\image latex \1\n\if DontIgnorePlantUMLCode"
ALIASES += "enduml=\endif"

Now, you can just do:

@startuml{myfilename.png}
.. PlantUML code
@enduml

Starting with version 7560, PlantUML will recognize @startuml{myfilename.png} as @startuml myfilename.png or @startuml "myfilename.png"
Batch example (for Windows)

The following batch file is called for each source directory :

...
:: parameter %1 is the source directory
:: parameter %2 is the image output directory

:: set tools
SET GRAPHVIZ_DOT=d:\Programme\Dev\graphviz\bin\dot.exe
SET DOXYGEN_EXE=d:\Programme\Dev\doxygen\doxygen.exe
SET PLANTUML_JAR=d:\Programme\Dev\plantuml\plantuml.jar

:: set source dir
SET SOURCE_DIR=%1

:: set image output folder for plantuml / image source folder for doxygen
SET DOC_IMG_PATH=%2

:: change to source dir and save old dir on stack
PUSHD "%SOURCE_DIR%"

:: call plantuml.jar for current dir
java -jar %PLANTUML_JAR% -v -o "%DOC_IMG_PATH%" "./**.(c|cpp|doc|h)"

:: call doxygen for current dir (doxyfile)
%DOXYGEN_EXE% doxyfile

:: change to saved dir
POPD
...


Additionally inside doxyfile the configuration value for image folder (for @image command) is assigned:

...
IMAGE_PATH = $(DOC_IMG_PATH)
...


Batch example (for Linux)

#!/bin/sh
# Create *.png files from text @startuml code and output *.png images to ./doc-src/images folder
# Recusively search from current folder scanning *.c, *.cpp, *.h, and *.doc files
java  -Djava.awt.headless=true -jar $PLANTUML_JAR -v -o $PWD/doc-src/images  "./**.(c|cpp|doc|h)"
doxygen

C Source example (Using alias)
Here is an example how the comment is used for plantuml and doxygen in C source file:

...
/*!
* @brief This function sends compute requests to
* ZipComp-Task and waits for response:
*
* @startuml{ZipCmd_ZipComp_Communication.png}
*
* ZipCmd -> ZipComp: First Compute Request
* ZipCmd <-- ZipComp: First Compute Response
*
* ZipCmd -> ZipComp: Second Compute Request
* ZipCmd <-- ZipComp: Second Compute Response
*
* @enduml
*
* @return some value on success.
*/
unsigned int ZipCmd_ZipComp_Communication(unsigned short command, unsigned
char *buffer);
...


C Source example (Old version)
Here is an example how the comment is used for plantuml and doxygen in C source file:

...
/*!
* @brief This function sends compute requests to
* ZipComp-Task and waits for response:
* @image html ZipCmd_ZipComp_Communication.png
*
* <!-- Hide plantuml commands from Doxygen inside comment.
*  Note: Use of the Doxygen tag command to hide code in 1.7.3 will hide the Doxygen docs that follow.
*  Warning: Don't replaced plantuml commands '@' with '\' - it won't work.
* @startuml ZipCmd_ZipComp_Communication.png
*
* ZipCmd -> ZipComp: First Compute Request
* ZipCmd <-- ZipComp: First Compute Response
*
* ZipCmd -> ZipComp: Second Compute Request
* ZipCmd <-- ZipComp: Second Compute Response
*
* @enduml
* -->
*
* @return some value on success.
*/
unsigned int ZipCmd_ZipComp_Communication(unsigned short command, unsigned
char *buffer);
...


@image is used in doxygen to include an image in documentation. The image file name must be the same is used after @startuml command (here: ZipCmd_ZipComp_Communication.png).

相关文章推荐

PlantUML画复杂流程图

1.They are implicitly linked in their definition order. @startuml :Hello world; :This is on define...

PlantUML_Language_Reference_Guide

  • 2016年04月22日 13:25
  • 1.93MB
  • 下载

PlantUML语言参考手册中文版.pdf

  • 2017年08月01日 16:05
  • 1.96MB
  • 下载

在windows下atom上搭建PlantUML书写环境

介绍了一种在windows环境下atom编辑器上搭建PlantUML书写环境的方法。

IDEA PlantUML离线安装

  • 2017年06月07日 11:43
  • 4.96MB
  • 下载

plantuml的学习文档

  • 2014年10月15日 21:59
  • 1.54MB
  • 下载

PlantUML

PlantUMLis a component that allows to quickly write : sequence diagram,use case diagram,class dia...
  • gxp
  • gxp
  • 2012年03月27日 17:02
  • 2111

eclipse plantuml link方式安装插件

  • 2016年10月18日 16:36
  • 3.06MB
  • 下载

在Sublime Text 3安装PlantUML插件

概述 以前经常用visio画各种流程图,后来同事推荐在Sublime Text 3上使用PlantUML,写命令即可,画图简单高效。上网搜了一些安装教程,结合实践安装总结如下。 什么是PlantU...

idea中安装PlantUML文件

  • 2017年08月07日 12:44
  • 38.7MB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Doxygen and plantuml
举报原因:
原因补充:

(最多只允许输入30个字)