我正在尝试编写一些 Doxygen 注释块,并且我想包含示例代码片段。当然,我希望这些示例能够实际编译,这样它们就不会过时。
我的 example.cpp(我在 .h 文件中包含)如下所示:
#include "stdafx.h"
#include "../types_lib/Time_Limiter.h"
#include <vector>
void tl_demo () {
// scarce will be a gate to control some resource that shouldn't get called
// more than 10 times a second
Time_Limiter scarce (10);
// here's a bunch of requests
std::vector<int> req (500);
for (size_t i=0;i<req.size ();i++) {
scarce.tick ();
// once we get here, we know that we haven't ticked
// more than 10 times in the last second.
// do something interesting with req[i]
}
}
// endcode
我的头文件(我正在运行 Doxygen)看起来像这样:
/**
* \ingroup types_lib
*
* \class Time_Limiter
*
* \brief Thread safe gate used to control a resource (such as an internet quote service) that has a limit on how often you can call it.
*
* \dontinclude Time_Limiter_example.cpp
* \skipline void
* \until endcode
*
**/
而且我想让 doxygen 只包含从“void demo”开始到文件末尾的东西(但没有 // endcode)。
我尝试过使用 \dontinclude 和 \skip、\skipline 和 \until 进行试验,但我无法完全弄清楚正确的咒语。
编辑:包括我的 .h 文件,现在我几乎得到了正确的咒语。这几乎完全符合我的要求,是否有某种方法可以在没有标签的情况下使用 \until,并从 example.cpp 中删除最后的 // endcode 行?