我正在尝试编写一些Doxygen注释块,并且我想包含示例代码片段。当然,我希望这些示例能够真正编译,以免它们过时。如何在Doxygen注释中包含.cpp文件的子集?
我example.cpp(即I \包括在.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和\试验,直到我不能完全弄清楚正确的咒语。
编辑:包括我的.h文件,现在我几乎得到正确的咒语。这是几乎正是我想要的,有没有一种方法来使用\直到没有标签,并摆脱最后一个//从example.cpp endcode行?
您是否正确设置了doxyfile中的EXAMPLE_PATH? – 2009-10-16 17:56:25
是的。包含的文本,我只是想找出一些咒语,所以我不必在开始时看到三个#includes。 – 2009-10-16 17:59:09
而你在http://www.stack.nl/~dimitri/doxygen/commands.html#cmddontinclude上看到了这个例子吗? – 2009-10-16 18:05:26