7
votes

I'm trying to get Doxygen to ignore an inheritance relationship when drawing collaboration diagrams.

Let's say my class definition looks like this:

class Derived : public Base
{
  int x;
  int y;
  int z;
}

Now, when I run Doxygen, I don't want to see Base class in the generated collaboration diagram.

At first glance, it seems that the cleanest way to do this would be to use the EXCLUDE_SYMBOLS directive in my Doxyfile. Specifically:

EXCLUDE_SYMBOLS = Base

However, I've found that this does not work: The Base class still shows up in my collaboration diagram for Derived. I've tried this on both Doxygen 1.8.6 and 1.8.11 and with different permutations of Base wildcards (Base*, *as*, etc), same behavior. The Base class always shows up in my collaboration diagram.

To be fair, I have found 2 workarounds, but they both involve putting conditional statements into my code. For completeness, I'll include both here:

First Workaround Method:

class Derived : 
#ifndef DOXYGEN_SHOULD_SKIP_THIS
    public Base
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
{
  ...
}

Then ensure that the following two directives are set inside the Doxyfile:

PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS
ENABLE_PREPROCESSING = YES

Second Workaround Method:

class Derived : 
/// @cond DOXYGEN_IGNORE
        public Base
/// @endcond
{
  ...
}

To be clear, these workarounds do indeed make Doxygen ignore the inheritance relationship, but I'd prefer not to unnecessarily pollute my code base, especially if there's a better / cleaner way to accomplish my goal.

My question is -- Why doesn't EXCLUDE_SYMBOLS make Doxygen ignore my Base class when it draws the collaboration diagram?

1

1 Answers

0
votes

If i am not mistaken, EXCLUDE_SYMBOLS prevents Doxygen from generating documentation for the excluded symbols, but it does not hide them. This means Doxygen won't generate documentation for your Base class, but it will still mention it as the base class of Derived, just like if Derived inherited from a class provided by an external library, the name of the class provided by the library would appear in the collaboration diagram.