我正在使用它doxygen version 1.8.8来构建 C++ 文档。我对模板类进行了详细描述,如下所示:
/** A test class. Detailed description of the test class
* Usage:
* @code
* test a;
* @endcode
*/
template<>
class test
{
//some class
};
Run Code Online (Sandbox Code Playgroud)
并希望在名为的文件中包含一个示例testexample.cpp
如果我只是将 放在@example详细描述的末尾,则详细描述将应用于该示例。
/** A test class. Detailed description of the test class
* Usage:
* @code
* test a;
* @endcode
* @example testexample.cpp
* An example of the test class.
*/
template<>
class test
{
//some class
};
Run Code Online (Sandbox Code Playgroud)
如何获得该类的详细描述以及示例文件的链接,以详细方式显示该类的用法?
在 doxygen 示例中,@example它们引用了成员变量的示例。该示例链接到该成员函数。这不是我希望在这种情况下实现的目标,因为我想展示如何在一个完整的工作示例中使用该类,而不仅仅是在使用说明中。
Doxygen 处理示例的方式是,代码示例是独立于常规文档的页面。就像or@example一样:它获取整个文档块并将其应用到示例页面。在该示例代码中使用的任何记录实体都将通过该示例的链接来增强其文档。@page@module
所以你需要的是一个独立的文档块,如下所示:
/**
* @example testexample testexample.cpp
* An example of the test class.
*/
Run Code Online (Sandbox Code Playgroud)
这不必与您的test班级位于同一文件中。
收到nicol的答复后,我通过以下方式实现了我所寻找的目标:
/** A test class. Detailed description of the test class
* Usage:
* @code
* test a;
* @endcode
*/
template<>
class test
{
//some class
};
/**@example TestExample.cpp
* Simple example of how to use the test class
*/
Run Code Online (Sandbox Code Playgroud)
EXAMPLE_PATH我已经尝试过这种方式,但因为我没有在示例中设置 ,所以Doxyfile无法找到该标签,因此该@example标签变得毫无用处。指定后一切EXAMPLE_PATH都按预期工作。