使用Doxygen记录命名空间

Tho*_*ews 26 c++ doxygen namespaces documentation-generation doxygen-addtogroup

我遇到了Doxygen识别命名空间和模块的问题.我认为问题围绕着是\addtogroup在命名空间内还是在命名空间之外.

示例1,在命名空间之外:

/*!
 *  \addtogroup Records
 *  @{
 */

//! Generic record interfaces and implementations
namespace Records
{

  //! Describes the record interface  
  class Interface;

} // End namespace Records

/*! @} End of Doxygen Groups*/
Run Code Online (Sandbox Code Playgroud)

示例2 - 在命名空间内

//! Generic record interfaces and implementations
namespace Records
{
/*!
 *  \addtogroup Records
 *  @{
 */


  //! Describes the record interface  
  class Interface;

/*! @} End of Doxygen Groups*/

} // End namespace Records
Run Code Online (Sandbox Code Playgroud)

我希望它namespace Records出现在Doxygen Namespaces选项卡下,间接出现在Modules选项卡下.单击" 命名空间"页面中的项目应生成包含的页面Records::Interface.单击" 模块"选项卡中的项目也应生成包含的页面Records::Interface.

在我的Doxygen文档中,我在Namespaces选项卡中缺少项目,这些项目位于模块中,反之亦然,原因是由于这种困境导致我的不一致.

那么哪个是正确的方法,例1还是例2?{Doxygen手册不清楚这个主题.}
Doxygen:\ addtogroup
Doxygen:记录名称空间

Tho*_*ews 31

我使用Doxygen和两个例子进行了实验,结果如下.示例中的类名已重命名,以避免与Doxygen混淆.

示例1,外部命名空间

/*!
 *  \addtogroup Records
 *  @{
 */

//! Generic record interfaces and implementations
namespace Records
{

  //! Describes the record interface  
  class Interface;

} // End namespace Records

/*! @} End of Doxygen Groups*/
Run Code Online (Sandbox Code Playgroud)

Doxygen结果:

单击"模块"按钮(在主栏中).
单击窗口中的"记录"模块.

记录和命名空间屏幕快照

示例2:在命名空间内(重命名为Fields的类)

//! Generic record interfaces and implementations
namespace Fields
{
/*!
 *  \addtogroup Fields
 *  @{
 */


  //! Describes the record interface  
  class Interface;

/*! @} End of Doxygen Groups*/

} // End namespace Fields
Run Code Online (Sandbox Code Playgroud)

Doxygen结果:

单击"模块"按钮(在主栏中).
单击窗口中的"记录"模块.

记录和命名空间在命名空间内屏幕快照

摘要

Doxygen \addtogroup命令的位置具有不同的结果,具体取决于它是位于namespace定义内还是位于外部.在命名空间外声明时,Doxygen Modules选项卡将显示命名空间,如上面的示例1所示.当\addtogroup命令放在命名空间内时,Doxygen Modules选项卡将不显示命名空间,如上面的示例2所示. 如果希望在Doxygen Modules选项卡中列出\addtogroup命名空间,请在命名空间外部找到命令.

  • @MPelletier:添加了新图片,以及访问相关网页的步骤. (2认同)

Joh*_*ohn 5

作为替代方案,您还可以在命名空间文档中使用:\ingroupRecords

/**
 * \defgroup Records Title for records module
 * @brief Short doc of Records
 *
 * Long doc of Records.
 */

/**
 * @brief Generic record interfaces and implementations
 *
 * \ingroup Records
 */
namespace Records {
    /// Describes the record interface  
    class Interface;

} /* namespace Records */
Run Code Online (Sandbox Code Playgroud)