在Doxygen中使用typedef的模板类(C++)

9

我的问题与如何在Doxygen中为模板类注释typedef有关。我将举一个例子来说明我的问题:

 namespace fundamental
  {
    /**
    * Basic function
    */
    template <typename T>
    class Base
    {
    public:
      T x; ///< x coordinate
      T y; ///< y coordinate
    };
    typedef Base<float> Coordinate; ///< Point coordinate class
  }

使用Doxygen处理以上代码后,我可以获得一个HTML页面来显示Base类的定义。然而,对于typedef类Coordinate,它不会出现在与Base相同的页面中。实际上,所有typedef类型都列在基本命名空间页面中,以及该命名空间中的所有类。我想知道是否可能在Base HTML页面中显示Coordinate类。通过这样做,Base和Coordinate之间的链接将变得更加紧密。谢谢!
6个回答

5

typedef 是命名空间的一部分,因此您必须记录该命名空间以便其出现,即:

/// documentation for the namespace
namespace fundamental
{
   ...
   typedef Base<float> Coordinate; ///< Point coordinate class
}

或者你可以使用@relates,但这会将成员放在基类的相关函数下方:

/// @relates Base
/// Point coordinate class
typedef Base<float> Coordinate;

您可以通过使用doxygen -l创建布局文件,然后编辑生成的DoxygenLayout.xml中的两个related元素来将此标题更改为相关成员等。

<related title="Related Members"/>

3
我在手册中读到以下内容:

在手册中,我读到以下内容:

让我们重复一遍,因为它经常被忽视:要记录全局对象(函数、typedef、枚举、宏等),必须记录定义它们的文件。换句话说,在该文件中至少必须有

/*! \file *//** @file */ 行。


2

这里有个"另请参见" (@sa) 命令,用于生成到其他实体的交叉引用。


1

您也可以使用/sa命令手动在Base页面中放置引用。

namespace fundamental
{
  /**
  * Basic function
  * /sa Coordinate
  */
  template <typename T>
  class Base
  {
  public:
    T x; ///< x coordinate
    T y; ///< y coordinate
  };
  typedef Base<float> Coordinate; ///< Point coordinate class
}

0
其他答案是可行的,但如果你的typedefBase类紧密相关,你希望它们出现在同一个Doxygen页面中,你可以考虑定义一个新的namespace(在Fundamental内),它将只包括Base和你的typedef。然后,doxygen将为该namespace生成一个页面,其中包括Base和你的typedef
定义一个file文档将达到相同的效果,但这可能是你的代码更合理的布局。

0

这个问题还有另外两个解决方案。你可以使用 @defgroup 关键字定义组,将类和 typedef 类型分组到一个模块中。另一种解决方案是使用 @relates


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接