Graphviz + Doxygen to generate UML class diagrams

73,827

Solution 1

Create the following source file 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();
};

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

EXTRACT_ALL            = YES
HAVE_DOT               = YES
UML_LOOK               = YES

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.

Solution 2

I had similar problem its successfully solved now.

Following are the steps(assuming that you are using GUI version of Doxygen-Doxywizard)

  1. Click on Expert button

  2. Go to Dot tab and select the DOT_PATH. Browse the folder where you have installed the program. e.g., " C:/Program Files (x86)/Graphviz2.32/bin "

Hope it helps, Anit

Solution 3

Try Doxygraph!

Doxygraph is a collection of tools to automate reverse engineering UML class diagrams from your project's source code, and present them as interactive web apps.

It relies on Doxygen to parse your source code and create an intermediate XML representation of the information it collects, so it supports all the same programming languages that Doxygen supports: C, C++, C#, Objective C, Java, Python, PHP, Tcl, D, IDL, VHDL, and Fortran.

You need to read the README from the cloned Project.

Solution 4

A possible solution to achieve your result is to use plantuml, but it requires more work on documentation.

Share:
73,827
Eric
Author by

Eric

Updated on October 16, 2020

Comments

  • Eric
    Eric over 3 years

    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?

    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.

    enter image description here

  • Derek
    Derek over 10 years
    Is there a way to have the return types displayed?
  • UndeadDragon
    UndeadDragon about 9 years
    Did you find a way to display return types, @Derek?
  • Knitschi
    Knitschi over 8 years
    This seems to be the right tool when you do not want to generate generic diagrams from the real code but rather have extra "diagram code" in the documentation that generates hand-crafted diagrams. This is exactly what I was looking for.
  • benathon
    benathon over 7 years
    The link is broken
  • Admin
    Admin almost 7 years
    See stackoverflow.com/questions/4755913/… for a more complete answer
  • Manish Jain
    Manish Jain about 5 years
    This is not an answer of the asked question. You should write this as a comment