如何(有选择地)禁用自动链接到doxygen中的示例

发布于 2025-01-21 11:48:48 字数 1786 浏览 1 评论 0原文

我有以下问题:我想将代码示例添加到我的doxygen文档中。它可以正常工作,但是我有很多示例,每个示例都需要调用相同的功能,例如 myinit()。现在, myinit()的生成文档包含所有使用 myinit()的示例,这基本上是指:所有示例。我想为 myinit()提到的一个一个,即,它证明了它的用法,但不是全部。

这是一个示例:

=============== 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 = .

这是结果(doxygen 1.8.7):

“在此处输入图像描述”

在我的真实情况下,它不仅是四个示例,而且是数十个示例。但是,在 Turnon的文档中,我只想出现 earpurnon.cpp

有什么想法吗?

再见, 洛基

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拔了角的鹿 2025-01-28 11:48:48

不是解决问题的答案,而是解决问题。

Doxygen中的输出对我来说也有些奇怪,但是也许有一个原因。
看来文件开头提到的示例不仅在类级别上,而且在类方法中(部分)提到。

我建议的是第一个解决方法:

/** \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() {}
};

并在Doxyfile中设置:

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

或者适用于1.8.7版本:

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

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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文