簡體   English   中英

時間:2019-05-06 標簽:c++doxygen\\example和description

[英]c++ Doxygen \example and description

我正在使用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
};

並希望在名為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
};

我如何獲得該類的詳細描述以及指向以詳細方式顯示該類用法的示例文件的鏈接?

@example的 doxygen 示例中,他們引用了一個成員變量的示例。 該示例鏈接到此成員函數。 這不是我希望在這種情況下實現的目標,因為我想展示如何在一個完整的示例中使用這個類,而不僅僅是在使用說明中。

Doxygen 處理示例的方式是代碼示例是與常規文檔不同的頁面。 所以@example就像@page@module :它獲取整個文檔塊並將其應用於示例頁面。 並且在該示例代碼中使用的任何文檔化實體都將使用指向該示例的鏈接擴充其文檔。

所以你需要的是一個像這樣的獨立文檔塊:

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

這不必與您的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
 */

我已經嘗試過這種方式,但是因為我沒有在Doxyfile設置EXAMPLE_PATH ,所以無法找到該示例,因此@example標記變得無用。 指定EXAMPLE_PATH后,一切都按預期工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM