Vscode⾃动⽣成Doxygen格式注释
前⾔
程序中注释的规范和统⼀性的重要性不⾔⽽喻,本⽂就推荐⼀种在⽤vscode编写代码时⾃动化⽣成标准化注释格式的⽅法,关于Doxygen 规范及其使⽤可查看博⽂。
本⽅法仅作为Doxygen注释的辅助作⽤。
Vs code⾃动⽣成Doxygen格式注释
环境
Vs code
Generate Doxygen Comments 插件
Generate Doxygen Comments 插件使⽤及配置
安装插件后,File--Preferences--Settings-- 中打开⽤户 setting.json⽂件
初步设置后如下所⽰:
{
"Level": 0,
"abled": false,
"python.pythonPath": "C:\\Users\\jordan\\AppData\\Local\\Programs\\Python\\Python37\\",
"workbench.iconTheme": "vscode-icons",
"explorer.autoReveal": false,  //取消左侧⾃动聚焦
"terminal.integrated.shell.windows": "D:\\Program Files\\Git\\bin\\",
"al.windowsExec": "D:\\Program Files\\Git\\bin\\",
"abled": true,
// Doxygen documentation generator set
"pyrightTag": [
"@copyright Copyright (c) {year}  XX通信公司"
],
"doxdocgen.file.customTag": [
"@par 修改⽇志:",
"<table>",
"<tr><th>Date      <th>Version <th>Author  <th>Description",
"<tr><td>{date} <td>1.0    <td>wangh    <td>内容",
"</table>",
],
"doxdocgen.file.fileOrder": [
"file",
"brief",
"author",
"version",
"date",
"empty",
"copyright",
"empty",
"custom"
],
"doxdocgen.file.fileTemplate": "@file {name}",
"doxdocgen.file.versionTag": "@version 1.0",
"ic.authorEmail": "wanghuan3037@fiberhome",
"ic.authorName": "wangh",
"ic.authorTag": "@author {author} ({email})",
"der": [
"brief",
"tparam",
"param",
"return"
],
"ic.paramTemplate": "@param{indent:8}{param}{indent:25}My Param doc",
"urnTemplate": "@return {type} ",
"ic.splitCasingSmartText": true,
}
解释如下:
{
// Doxygen documentation generator set
// ⽂件注释:版权信息模板
"pyrightTag": [vscode代码规范
"@copyright Copyright (c) {year}  XX通信公司"
],
// ⽂件注释:⾃定义模块,这⾥我添加⼀个修改⽇志
"doxdocgen.file.customTag": [
"@par 修改⽇志:",
"<table>",
"<tr><th>Date      <th>Version <th>Author  <th>Description",
"<tr><td>{date} <td>1.0    <td>wangh    <td>内容",
"</table>",
],
// ⽂件注释的组成及其排序
"doxdocgen.file.fileOrder": [
"file",  // @file
"brief", // @brief 简介
"author", // 作者
"version", // 版本
"date",  // ⽇期
"empty", // 空⾏
"copyright",// 版权
"empty",
"custom" // ⾃定义
],
// 下⾯时设置上⾯标签tag的具体信息
"doxdocgen.file.fileTemplate": "@file {name}",
"doxdocgen.file.versionTag": "@version 1.0",
"ic.authorEmail": "wanghuan3037@fiberhome",
"ic.authorName": "wangh",
"ic.authorTag": "@author {author} ({email})",
// ⽇期格式与模板
"ic.dateFormat": "YYYY-MM-DD",
"ic.dateTemplate": "@date {date}",
// 根据⾃动⽣成的注释模板(⽬前主要体现在函数注释上)
"der": [
"brief",
"tparam",
"param",
"return"
]
,
"ic.paramTemplate": "@param{indent:8}{param}{indent:25}My Param doc",    "urnTemplate": "@return {type} ",
"ic.splitCasingSmartText": true,
}
效果如下:
当在⽂件头部输⼊ “/**” 后回车,效果如下:
/**
* @file main.c
* @brief
* @author wangh (xxxxxxx@fiberhome)
* @version 1.0
* @date 2019-11-17
*
* @copyright Copyright (c) 2019  XX通信公司
*
* @par 修改⽇志:
* <table>
* <tr><th>Date      <th>Version <th>Author  <th>Description
* <tr><td>2019-11-17 <td>1.0    <td>wangh    <td>内容
* </table>
*/
在函数上⾯ “/**” 后回车,效果如下:
/
**
* @brief
* @param  buffer          My Param doc
* @param  len              My Param doc
* @return int
*/
int platform_oled_write(uint8_t *buffer, uint16_t len);

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。