Graphviz + Doxygen to generate UML class diagrams

后端 未结 4 1825
暗喜
暗喜 2020-11-29 21:40

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 suppo

4条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 21:57

    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.

提交回复
热议问题