How to (selectively) disable auto-links to examples in Doxygen

243 views Asked by At

I have the following problem: I want to add code examples to my doxygen documentation. It works fine, but I have quite some examples, each of which needs to call the same function, say, myInit(). Now, the generated documentation for myInit() contains all examples that use myInit(), which basically means: all examples. I would like to have exactly one example referred to for myInit(), namely that one which demonstrates the usage of it, but not all of them.

Here is an example:

=============== MyEspressoMachine.h ==============
/** @example exTurnOn.cpp */
/** @example exMakeEspresso.cpp */
/** @example exClean.cpp */
/** @example exTurnOff.cpp */

/** My espresso machine. */
class MyEspressoMachine {
public:
    /** Turns the espresso machine on */
    void turnOn() {};
    /** Makes a delicious espresso.  */
    void makeEspresso() {};
    /** Cleans the espresso machine.  */
    void clean() {};
    /** Turns the espresso machine off */
    void turnOff() {};
};
=============== exTurnOn.cpp =============
#include "MyEspressoMachine.h"
int main() {
    MyEspressoMachine m;
    m.turnOn();
    m.turnOff();
}
=============== exMakeEspresso.cpp ==============
#include "MyEspressoMachine.h"
int main() {
    MyEspressoMachine m;
    m.turnOn();
    m.makeEspresso();
    m.turnOff();
}
=============== exClean.cpp ==============
#include "MyEspressoMachine.h"
int main() {
    MyEspressoMachine m;
    m.turnOn();
    m.clean();
    m.turnOff();
}
=============== exTurnOff.cpp ==============
#include "MyEspressoMachine.h"
int main() {
    MyEspressoMachine m;
    m.turnOn();
    m.turnOff();
}
=============== Doxyfile ==============
EXAMPLE_PATH = .

Here is the result (Doxygen 1.8.7):

enter image description here

In my real case, it's not only four examples, but dozens. Though, in the documentation for turnOn, I only want exTurnOn.cpp to appear.

Any ideas?

bye, loki

1

There are 1 answers

1
albert On

Not an answer to solve the problem, but more a workaround.

The output in doxygen is a bit strange to me too, but maybe there is a reason for this. It looks like that the examples mentioned at the beginning of the file are not only mentioned on the class level but also (partly) in the class methods.

Al a first workaround I would suggest:

/** \file */

/** My espresso machine. */
class MyEspressoMachine {
public:
    /** Turns the espresso machine on
     *
     * @myExample exTurnOn.cpp
     */
    void turnOn() {}
    /** Makes a delicious espresso.
     *
     * @myExample exMakeEspresso.cpp
     */
    void makeEspresso() {}
    /** Cleans the espresso machine.
     *
     * @myExample exClean.cpp
     */
    void clean() {}
    /** Turns the espresso machine off
     *
     * @myExample exTurnOff.cpp
     */
    void turnOff() {}
};

and setting in the Doxyfile:

ALIASES = myExample="**Example:** ^^ @include"

or for the 1.8.7 version:

ALIASES = myExample="**Example:** \n @include"