是否有减少完整 Doxygen 覆盖所需的冗余注释量的技巧?
Is there a trick to reduce the amount of redundant commenting required for full Doxygen coverage?
作为记录我的 C++ 代码库的一部分,我试图获得完整的 Doxygen 覆盖——也就是说,我希望我所有的(数百个)头文件都具有格式良好的 Doxygen 注释。 public API,这样我就可以在代码库上 运行 Doxygen 而不会看到任何 "warning: blah is not documented" 警告。
一般来说,这只是浏览和记录内容的问题,但我注意到我一直在为每个 class 一遍又一遍地输入相同的文本。例如,我有很多这样的实例:
/** The Foo class represents blah blah blah */
class Foo
{
public:
/** Default constructor */
Foo();
/** Copy constructor
* @param rhs the object to make this object a copy of.
*/
Foo(const Foo & rhs);
/** Destructor */
~Foo();
/** Equality operator.
* @param rhs the object to compare against.
* @returns true iff this object and (rhs) are equal.
*/
bool operator == (const Foo & rhs) const;
/** Inequality operator.
* @param rhs the object to compare against.
* @returns true iff this object and (rhs) are not equal.
*/
bool operator != (const Foo & rhs) const;
/** Assignment operator
* @param rhs the object we should copy our state from
* @returns a reference to *this
*/
Foo & operator = (const Foo & rhs);
[...]
}
这些评论(通常)对每个 class 都或多或少完全相同,因为这些 functions/operators 几乎总是对每个 class 以完全相同的方式工作。事实上,让运算符或复制构造函数以其他方式运行将是一个有问题的设计模式,因为 C++ 程序员通常希望运算符对每个 class.
以相同的方式工作。
我的问题是,是否有一些技巧可以让 Doxygen 自动为这些东西生成合理的文档(例如,通过某种模板或宏),而不必一遍又一遍地手动输入这些文本?这将大大减少我必须输入和维护的文本量,而且它还可以通过允许我删除 "no duh" 种类的注释来使我的头文件变得杂乱无章,以便 reader 可以更容易找到提供真正见解的评论。
复制文档有几个命令:
\copydoc
\copybrief
\copydetails
Doxygen 帮助建议使用以下语法:
/*! @copydoc MyClass::myfunction()
* More documentation.
*/
这允许您将文档从一个 class 复制到另一个。有时我只生成一个文档 class 并没有编译为从项目的其余部分提取文档的标准位置。
作为记录我的 C++ 代码库的一部分,我试图获得完整的 Doxygen 覆盖——也就是说,我希望我所有的(数百个)头文件都具有格式良好的 Doxygen 注释。 public API,这样我就可以在代码库上 运行 Doxygen 而不会看到任何 "warning: blah is not documented" 警告。
一般来说,这只是浏览和记录内容的问题,但我注意到我一直在为每个 class 一遍又一遍地输入相同的文本。例如,我有很多这样的实例:
/** The Foo class represents blah blah blah */
class Foo
{
public:
/** Default constructor */
Foo();
/** Copy constructor
* @param rhs the object to make this object a copy of.
*/
Foo(const Foo & rhs);
/** Destructor */
~Foo();
/** Equality operator.
* @param rhs the object to compare against.
* @returns true iff this object and (rhs) are equal.
*/
bool operator == (const Foo & rhs) const;
/** Inequality operator.
* @param rhs the object to compare against.
* @returns true iff this object and (rhs) are not equal.
*/
bool operator != (const Foo & rhs) const;
/** Assignment operator
* @param rhs the object we should copy our state from
* @returns a reference to *this
*/
Foo & operator = (const Foo & rhs);
[...]
}
这些评论(通常)对每个 class 都或多或少完全相同,因为这些 functions/operators 几乎总是对每个 class 以完全相同的方式工作。事实上,让运算符或复制构造函数以其他方式运行将是一个有问题的设计模式,因为 C++ 程序员通常希望运算符对每个 class.
以相同的方式工作。我的问题是,是否有一些技巧可以让 Doxygen 自动为这些东西生成合理的文档(例如,通过某种模板或宏),而不必一遍又一遍地手动输入这些文本?这将大大减少我必须输入和维护的文本量,而且它还可以通过允许我删除 "no duh" 种类的注释来使我的头文件变得杂乱无章,以便 reader 可以更容易找到提供真正见解的评论。
复制文档有几个命令:
\copydoc
\copybrief
\copydetails
Doxygen 帮助建议使用以下语法:
/*! @copydoc MyClass::myfunction()
* More documentation.
*/
这允许您将文档从一个 class 复制到另一个。有时我只生成一个文档 class 并没有编译为从项目的其余部分提取文档的标准位置。