Documenting functions in C++ with Doxygen

时间:2022-12-20 00:06:55

I've got a project that I'm using Doxygen to generate documentation to. The documentation of the classes is fine, but I've also got some functions that I use in main() to create objects etc. I'd also like to have these into my documentation, but I have not figured how to do that. Any suggestions?

我有一个项目,我正在使用Doxygen生成文档。这些类的文档很好,但我也有一些函数,我在main()中使用它来创建对象等。我也想将这些函数放入我的文档中,但我还没有想到如何做到这一点。有什么建议么?

4 个解决方案

#1


9  

Use \fn where you otherwise use \class in your \\*! *\ block

使用\ fn,否则在\\ *中使用\ class! * \块

http://www.doxygen.nl/docblocks.html
look for "Documentation at other places"

http://www.doxygen.nl/docblocks.html寻找“其他地方的文档”

http://www.doxygen.nl/commands.html#cmdfn
It works similar as documenting member functions

http://www.doxygen.nl/commands.html#cmdfn它与记录成员函数类似

#2


21  

Entities that are members of classes are only documented if their class is documented. Entities declared at namespace scope are only documented if their namespace is documented. Entities declared at file scope are only documented if their file is documented.

作为类成员的实体仅在其类记录时才会记录。在命名空间范围内声明的实体仅在记录其命名空间时才会记录。在文件范围内声明的实体仅在其文件记录时才会记录。

So to document a free function in the global namespace you also need a line like this somewhere in the header file in which it is declared:

因此,要在全局命名空间中记录一个*函数,您还需要在头文件中的某个位置声明它:

/** @file */

Or like this:

或者像这样:

/*! \file */

#3


5  

This pattern worked well for us.

这种模式对我们很有用。

/*! Convert counts to kg for the reservoir.  
    \param counts The A/D counts to convert.` 
    \return The calculated kg based on the parameter.  
*/  
float RES_ConvertCountsToValue(uint_16 counts);  

#4


2  

I like this pattern

我喜欢这种模式

   ///////////////////////////////////////////////////////////////////////
   /// \brief setX
   /// \param x offset of the image.
   /// \return a new image as an QImage.
   /////////////////////////////////////////////////////////////////////////
    QImage  setX(int x);

#1


9  

Use \fn where you otherwise use \class in your \\*! *\ block

使用\ fn,否则在\\ *中使用\ class! * \块

http://www.doxygen.nl/docblocks.html
look for "Documentation at other places"

http://www.doxygen.nl/docblocks.html寻找“其他地方的文档”

http://www.doxygen.nl/commands.html#cmdfn
It works similar as documenting member functions

http://www.doxygen.nl/commands.html#cmdfn它与记录成员函数类似

#2


21  

Entities that are members of classes are only documented if their class is documented. Entities declared at namespace scope are only documented if their namespace is documented. Entities declared at file scope are only documented if their file is documented.

作为类成员的实体仅在其类记录时才会记录。在命名空间范围内声明的实体仅在记录其命名空间时才会记录。在文件范围内声明的实体仅在其文件记录时才会记录。

So to document a free function in the global namespace you also need a line like this somewhere in the header file in which it is declared:

因此,要在全局命名空间中记录一个*函数,您还需要在头文件中的某个位置声明它:

/** @file */

Or like this:

或者像这样:

/*! \file */

#3


5  

This pattern worked well for us.

这种模式对我们很有用。

/*! Convert counts to kg for the reservoir.  
    \param counts The A/D counts to convert.` 
    \return The calculated kg based on the parameter.  
*/  
float RES_ConvertCountsToValue(uint_16 counts);  

#4


2  

I like this pattern

我喜欢这种模式

   ///////////////////////////////////////////////////////////////////////
   /// \brief setX
   /// \param x offset of the image.
   /// \return a new image as an QImage.
   /////////////////////////////////////////////////////////////////////////
    QImage  setX(int x);