Doxygen--->C/C++代码格式管理,自动生成一些文档

  • Doxygen注释块其实就是在C、C++注释块的基础添加一些额外标识,使Doxygen把它识别出来, 并将它组织到生成的文档中去。
  • 我们在编写代码的时候,最头疼的就属于说明书了,很多代码一边写具体代码,一边写说明书,Doxygen主要解决说明书问题,可以在我们写代码的时候讲注释转化为说明书

编写规范

常用指令

在这里插入图片描述

1.文件注释

/**
  * @file     	sensor.c
  * @author   	JonesLee
  * @email   	Jones_Lee3@163.com
  * @version	V4.01
  * @date    	07-DEC-2017
  * @license  	GNU General Public License (GPL)  
  * @brief   	Universal Synchronous/Asynchronous Receiver/Transmitter 
  * @detail		detail
  * @attention
  *  This file is part of OST.                    \n
  */  

2.类和成员注释

/**
* @class <class‐name> [header‐file] [<header‐name]
* @brief brief description
* @author <list of authors>
* @note
* detailed description
*/

如果对文件、结构体、联合体、类或者枚举的成员进行文档注释的话,并且要在成员中间添加注释,而这些注释往往都是在每个成员后面。为此,可以使用在注释段中使用’<'标识。

int var; /**< Detailed description after the member */

一个类的注释如下

class Test
{
public:
    /** @brief A enum, with inline docs */
    enum TEnum 
    {
        TVal1, /**< enum value TVal1. */ 
        TVal2, /**< enum value TVal2. */ 
        TVal3 /**< enum value TVal3. */ 
    } 
   *enumPtr, /**< enum pointer. */
    enumVar; /**< enum variable. */
    /** @brief A constructor. */ 
Test(); 
/** @brief A destructor. */ 
~Test();
 /** @brief a normal member taking two arguments and returning an integer value. */ 
    int testMe(int a,const char *s); 

    /** @brief A pure virtual member. 
    * @param[in] c1 the first argument. 
    * @param[in] c2 the second argument. 
    * @see testMe() 
    * /
};

3.函数注释

	/**
		* @brief		can send the message
		* @param[in]	canx : The Number of CAN
		* @param[in]	id : the can id	
		* @param[in]	p : the data will be sent
		* @param[in]	size : the data size
		* @param[in]	is_check_send_time : is need check out the time out
		* @note	Notice that the size of the size is smaller than the size of the buffer.		
		* @return		
		*	+1 Send successfully \n
		*	-1 input parameter error \n
		*	-2 canx initialize error \n
		*	-3 canx time out error \n
		* @par Sample
		* @code
		*	u8 p[8] = {0};
		*	res_ res = 0; 
		* 	res = can_send_msg(CAN1,1,p,0x11,8,1);
		* @endcode
		*/							
	extern s32 can_send_msg(const CAN_TypeDef * canx,
							const u32 id,
							const u8 *p,
							const u8 size,
							const u8 is_check_send_time);	

4.枚举注释

	/** bool */  
	typedef enum
    {
        false = 0,  /**< FALSE 0  */
        true = 1    /**< TRUE  1  */
    }bool;

安装与配置

参考1

参考

知乎

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在编写C++代码时,注释文档自动生成是一项非常有用的功能。可以通过使用特定的代码注释规范,如Doxygen或者JavaDoc,来生成注释文档Doxygen是一种流行的自动化文档生成工具,它可以根据代码中的特定注释格式来生成文档。在C++代码中,我们可以使用特定的注释语法来描述函数、类、变量等的用途、参数、返回值、示例等信息。例如,我们可以使用以下注释格式来描述一个函数: /** * @brief 该函数用于计算两个整数的和。 * * @param a 第一个整数 * @param b 第二个整数 * @return 两个整数的和 */ int sum(int a, int b) { return a + b; } 几乎所有的主要编程IDE(如Visual Studio、Eclipse等)都支持Doxygen注释的自动完成和文档预览。使用自动完成功能,我们可以快速生成函数、类、变量等的注释模板,并根据实际情况进行修改。当完成代码编写后,我们可以使用Doxygen生成注释文档。只需简单地运行Doxygen,并指定代码文件所在的目录,Doxygen将会扫描代码文件,并根据注释生成相应的HTML、PDF或其他格式文档。 使用自动化注释文档生成的好处是,我们可以将注释代码保持同步,并且文档的更新和维护变得更加容易。此外,还可以通过生成的文档提供给其他开发人员或用户查阅,使得代码更易于理解和使用。 总之,通过使用Doxygen等自动化文档生成工具,我们可以方便地生成C++代码注释文档,提高代码可读性和可维护性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值