2
votes

I'm using doxygen to generate the class diagram for a Qt-based solution. For better and for worse, most of our classes inherit from QObject which leads to somewhat crappy class diagrams with QObject on the left and all classes pointing to it.

Is there any way to make doxygen ignore QObject in the class diagram?

I have already tried EXCLUDE_SYMBOLS = QObject but it made no difference (I believe this only makes QObject's documentation not to be generated).

We are not actually using the documentation itself, so even a disrupting solution that would cause some strange behavior would be acceptable as long as we get a prettier version of the class diagram.

2

2 Answers

0
votes

Unfortunately, the only methods to solve this issue are all based on hiding certain parts of the code to Doxygen.

Preprocessor Directives

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

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

PREDEFINED = SKIP_THIS
ENABLE_PREPROCESSING = YES

Conditionals

This can be done through the usage of @cond and @endcond tags in your code. An example is shown below:

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

Internal Tag

To ignore a section of the code, one can simply enclose the appropriate parts using \internal and \endinternal. Be sure to set INTERNAL_DOCS to NO in the configuration file.

EXCLUDE_SYMBOLS

This excludes particular word regex from your documentation. It can also be set using the GUI through

"expert > input"

Thus, one could exclude everything from a particular namespace using the appropriate regex, which in this case is through the asterisk *. For example,

class X: public my_space::Y {
...
}

EXCLUDE_SYMBOLS = my_space::*
0
votes

I've also run into this problem. My solution is an outrageous hack, but does result in the desired effect. Basically I've got an impostor dot that's actually a shell script which looks for nodes labelled QObject and removes them from the input file. You can get Doxygen to use the impostor dot by setting the DOT_PATH DoxyFile value to the directory in which you put the impostor script.

#! /bin/bash

# This hack is a wrapper to GraphViz dot that removes any nodes that
# are contained in the following list.

LABELS_TO_FILTER="QObject"

ARGS=$@

for ARG in ${ARGS}
do
  if [ -e ${ARG} ]
  then
    FILENAME=$(basename "${ARG}")
    EXT="${FILENAME##*.}"

    if [ ${EXT} == "dot" ]
    then
      DOT_FILE=${ARG}

      for LABEL_TO_FILTER in ${LABELS_TO_FILTER}
      do
        NODE_NAME=$(grep "label=\"${LABEL_TO_FILTER}\"" ${DOT_FILE} | awk '{print $1}')

        if [[ ! -z "${NODE_NAME}" ]]
        then
          echo "${NODE_NAME} is labelled ${LABEL_TO_FILTER}, filtering..."
          sed -i "/${NODE_NAME}/d" ${DOT_FILE}
        fi
      done

      break
    fi
  fi
done

dot ${ARGS}