c++ Doxygen \例子和描述

c++ Doxygen \example and description

我正在使用 doxygen version 1.8.8 构建 C++ 文档。我包含了我的模板化 class 的详细描述如下:

/** A test class. Detailed description of the test class
 *  Usage:
 *  @code
 *    test a;
 *  @endcode
 */
template<>
class test
{
  //some class
};

并希望将示例包含到名为 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
};

如何将 class 和 link 的详细描述添加到详细说明 class 用法的示例文件中?

@example 的 doxygen 示例中,他们引用了一个成员变量的示例。这个例子是 linked 到这个成员函数。这不是我希望在这种情况下实现的,因为我想展示如何在一个完整的示例中使用这个 class 而不仅仅是在使用说明中。

Doxygen 使用示例的方式是代码示例是与常规文档分开的页面。所以 @example 就像 @page@module:它获取整个文档块并将其应用于示例页面。在该示例代码中使用的任何文档化实体都将通过 该示例的链接来扩充其文档。

所以您需要的是像这样的独立文档块:

/**
 *  @example testexample testexample.cpp
 *  An example of the test class.
 */

这不必与您的 test class.

在同一个文件中

收到 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
 */

我已经用这种方法试过了,但是因为我没有在 Doxyfile 中设置 EXAMPLE_PATH,所以无法找到示例,因此 @example 标签变得无用。在指定 EXAMPLE_PATH 之后,一切都按预期工作。