Graphviz + Doxygen生成UML类图 [英] Graphviz + Doxygen to generate UML class diagrams

查看:578
本文介绍了Graphviz + Doxygen生成UML类图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要使用 Graphviz + Doxygen 生成基于C ++代码的类图。由于Doxygen带有本机DOT支持,因此已经可以使用。但是是否可能产生具有类似访问权限修饰符(公共,私有等),类方法的返回值和参数类型的 UML样输出,类似于下图?

I want to use Graphviz + Doxygen to generate a class diagram based on C++ code. This works already as Doxygen comes with a native DOT support; but is it possible, to produce a UML-like output with the corresponding access modificators (public, private etc.), return and parameter types of the class methods, similar to the diagram below?

我知道线程如何使用doxygen从C ++源代码创建UML类图,但是并不能回答问题。

I'm aware of thread How to use doxygen to create UML class diagrams from C++ source, but it doesn't answer the question, though.

推荐答案

创建以下源文件 example.cpp

class Animal
{
  public:
    void die();
    string name;
    int age;
};

class Dog : public Animal
{
  public:
    void bark();
};

class Cat : public Animal
{
  public:
    void meow();
};

运行 doxygen -g 并更改以下内容生成的 Doxyfile的选项

run doxygen -g and change the following options of the generated Doxyfile:

EXTRACT_ALL            = YES
HAVE_DOT               = YES
UML_LOOK               = YES

运行 doxygen 并查看Animal类的输出,它应该与上图类似,尽管doxygen不会显示方法和字段的返回类型。

run doxygen and look at the output for the Animal class, it should be the similar as the above picture, although doxygen will not show the return types of the methods and fields.

这篇关于Graphviz + Doxygen生成UML类图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆