首页 > 其他分享 >vs code 技巧:使用Doxygen Documentation Generator自动添加注释

vs code 技巧:使用Doxygen Documentation Generator自动添加注释

时间:2023-01-11 16:22:06浏览次数:56  
标签:code name Generator author generic Documentation param file doxdocgen

安装

安装很简单,直接在插件里搜Doxygen Documentation Generator进行安装

网址:https://marketplace.visualstudio.com/items?itemName=cschlosser.doxdocgen&ssr=false#user-content-smart-text

默认配置

在插件的网址中可以看到插件对应效果和配置说明

相关配置可以在vscode配置中选择

也可以修改setting.json(推荐)

如下是示例配置

  // The prefix that is used for each comment line except for first and last.
  "doxdocgen.c.commentPrefix": " * ",

  // Smart text snippet for factory methods/functions.
  "doxdocgen.c.factoryMethodText": "Create a {name} object",

  // The first line of the comment that gets generated. If empty it won't get generated at all.
  "doxdocgen.c.firstLine": "/**",

  // Smart text snippet for getters.
  "doxdocgen.c.getterText": "Get the {name} object",

  // The last line of the comment that gets generated. If empty it won't get generated at all.
  "doxdocgen.c.lastLine": " */",

  // Smart text snippet for setters.
  "doxdocgen.c.setterText": "Set the {name} object",

  // Doxygen comment trigger. This character sequence triggers generation of Doxygen comments.
  "doxdocgen.c.triggerSequence": "/**",

  // Smart text snippet for constructors.
  "doxdocgen.cpp.ctorText": "Construct a new {name} object",

  // Smart text snippet for destructors.
  "doxdocgen.cpp.dtorText": "Destroy the {name} object",

  // The template of the template parameter Doxygen line(s) that are generated. If empty it won't get generated at all.
  "doxdocgen.cpp.tparamTemplate": "@tparam {param} ",

  // File copyright documentation tag.  Array of strings will be converted to one line per element.  Can template {year}.
  "doxdocgen.file.copyrightTag": [
    "@copyright Copyright (c) {year}"
  ],

  // Additional file documentation. One tag per line will be added. Can template `{year}`, `{date}`, `{author}`, `{email}` and `{file}`. You have to specify the prefix.
  "doxdocgen.file.customTag": [],

  // The order to use for the file comment. Values can be used multiple times. Valid values are shown in default setting.
  "doxdocgen.file.fileOrder": [
    "file",
    "author",
    "brief",
    "version",
    "date",
    "empty",
    "copyright",
    "empty",
    "custom"
  ],

  // The template for the file parameter in Doxygen.
  "doxdocgen.file.fileTemplate": "@file {name}",

  // Version number for the file.
  "doxdocgen.file.versionTag": "@version 0.1",

  // Set the e-mail address of the author.  Replaces {email}.
  "doxdocgen.generic.authorEmail": "[email protected]",

  // Set the name of the author.  Replaces {author}.
  "doxdocgen.generic.authorName": "your name",

  // Set the style of the author tag and your name.  Can template {author} and {email}.
  "doxdocgen.generic.authorTag": "@author {author} ({email})",

  // If this is enabled a bool return value will be split into true and false return param.
  "doxdocgen.generic.boolReturnsTrueFalse": true,

  // The template of the brief Doxygen line that is generated. If empty it won't get generated at all.
  "doxdocgen.generic.briefTemplate": "@brief {text}",

  // The format to use for the date.
  "doxdocgen.generic.dateFormat": "YYYY-MM-DD",

  // The template for the date parameter in Doxygen.
  "doxdocgen.generic.dateTemplate": "@date {date}",

  // Decide if you want to get smart text for certain commands.
  "doxdocgen.generic.generateSmartText": true,

  // Whether include type information at return.
  "doxdocgen.generic.includeTypeAtReturn": true,

  // How many lines the plugin should look for to find the end of the declaration. Please be aware that setting this value too low could improve the speed of comment generation by a very slim margin but the plugin also may not correctly detect all declarations or definitions anymore.
  "doxdocgen.generic.linesToGet": 20,

  // The order to use for the comment generation. Values can be used multiple times. Valid values are shown in default setting.
  "doxdocgen.generic.order": [
    "brief",
    "empty",
    "tparam",
    "param",
    "return",
    "custom",
    "version",
    "author",
    "date",
    "copyright"
  ],

  // Custom tags to be added to the generic order. One tag per line will be added. Can template `{year}`, `{date}`, `{author}`, `{email}` and `{file}`. You have to specify the prefix.
  "doxdocgen.generic.customTags": [],

  // The template of the param Doxygen line(s) that are generated. If empty it won't get generated at all.
  "doxdocgen.generic.paramTemplate": "@param {param} ",

  // The template of the return Doxygen line that is generated. If empty it won't get generated at all.
  "doxdocgen.generic.returnTemplate": "@return {type} ",

  // Decide if the values put into {name} should be split according to their casing.
  "doxdocgen.generic.splitCasingSmartText": true,

  // Array of keywords that should be removed from the input prior to parsing.
  "doxdocgen.generic.filteredKeywords": [],

  // Substitute {author} with git config --get user.name.
  "doxdocgen.generic.useGitUserName": false,

  // Substitute {email} with git config --get user.email.
  "doxdocgen.generic.useGitUserEmail": false,

  // Provide intellisense and snippet for doxygen commands
  "doxdocgen.generic.commandSuggestion": true,

  // Add `\\` in doxygen command suggestion for better readbility (need to enable commandSuggestion)
  "doxdocgen.generic.commandSuggestionAddPrefix": false

效果如下:

/**
 * @file XXX.c
 * @author your name ([email protected])
 * @brief 
 * @version 0.1
 * @date 2023-01-11
 * 
 * @copyright Copyright (c) 2023
 * 
 */

/**
 * @brief 
 * 
 * @param addr 
 * @param data 
 * @param length 
 * @return char 
 * @version 0.1
 * @author your name ([email protected])
 * @date 2023-01-11
 * @copyright Copyright (c) 2023
 */
char test_fun(uint8_t addr, uint8_t *data, uint8_t length)
{
}

自用配置分享

    "doxdocgen.file.copyrightTag": [
        "@copyright Copyright (c) {year} XXX ",
        "For study and research only, no reprinting",
    ],
    "doxdocgen.file.customTag": [
        "************************************************************************",
    ],
    "doxdocgen.file.fileOrder": [
        "custom",
        "empty",
        "file",
        "author",
        "brief",
        "empty",
        "custom",
        "copyright",
        "custom"
    ],
    "doxdocgen.generic.authorEmail": "[email protected]",
    "doxdocgen.generic.authorName": "XXX",
    "doxdocgen.generic.authorTag": "@author {author} ({email})",
    "doxdocgen.generic.order": [
        "custom",
        "brief",
        "empty",
        "param",
        "empty",
        "return",
        "custom",
    ],
    "doxdocgen.generic.customTags": [
        "************************************************************************"
    ],
    "doxdocgen.generic.paramTemplate": "@param[in] {indent:8}{param} {indent:8} Comment",
    "doxdocgen.generic.returnTemplate": "@return ",

效果如下:

/**
 * ************************************************************************
 * 
 * @file XXX.c
 * @author XXX ([email protected])
 * @brief 
 * 
 * ************************************************************************
 * @copyright Copyright (c) 2023 XXX 
 * For study and research only, no reprinting
 * ************************************************************************
 */
#include <stdio.h>

/**
 * ************************************************************************
 * @brief 
 * 
 * @param[in] addr  Comment
 * @param[in] data  Comment
 * @param[in] length  Comment
 * 
 * @return 
 * ************************************************************************
 */
char test_fun(uint8_t addr, uint8_t *data, uint8_t length)
{
}

标签:code,name,Generator,author,generic,Documentation,param,file,doxdocgen
From: https://www.cnblogs.com/simpleGao/p/17044136.html

相关文章

  • 为测试管理正名,华为云CodeArts TestPlan的守护之道
    摘要:华为云CodeArtsTestPlan既有公有云版本,也有下沉到私有云的版本。本文分享自华为云社区《​​为测试管理正名,华为云CodeArtsTestPlan的守护之道​​》,作者:云报。2023年......
  • 【BFS】LeetCode 103. 二叉树的锯齿形层序遍历
    题目链接103.二叉树的锯齿形层序遍历思路1额外加一个栈来使得访问节点的顺序是逆序的代码1classSolution{publicList<List<Integer>>zigzagLevelOrder(Tree......
  • active code page: 65001 提示去除
    Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\CommandProcessorPressWin+R.Type"regedit"andpress Enter.Navigatetothepath HKEY_LOCAL_MACHINE\SOFT......
  • Xcode无法显示图片
    热烈欢迎,请直接点击!!!进入博主AppStore主页,下载使用各个作品!!!注:博主将坚持每月上线一个新app!!!Xcode中的图片资源、图标,如果拿到的是jpg格式,不要直接通过重命名修改格式,因......
  • MLIR code slide
    点击查看代码//遍历一个functionfunc.walk([&](Operation*op){size_tnUser=llvm::count_if(op->getUsers(),[](auto*){returntrue;});unresolve......
  • LeetCode刷题:AddressSanitizer: heap-buffer-overflow问题请教||全局变量和引用传递的
    在刷https://leetcode.cn/problems/sudoku-solver/description/遇到AddressSanitizer:heap-buffer-overflow的报错。代码为://本题思路就是简单的回溯//注意限制:只......
  • 一个CF1775C(Codeforces Round #843 (Div. 2))的小技巧
    若\(n\)的第\(i\)位为\(1\),而我们需要不断令\(n+1\)找到下一个最小的\(k\),使得\(k\)的第\(i\)位为\(0\)。技巧:假设\(n\)为10101[1]1001,括号内是要求的第\(i\)位那么先......
  • ESP-IDF4.4 VScode安装问题
    一般安装ESP-IDF的环境是不会出错的,一路点击下去即可【ESP-IDFv4.4.3-OfflineInstaller下载地址】。主要是VScode安装ESP-IDF插件的时候会有以下两个问题WARNING:Y......
  • CF Codeforces Round #843 (Div. 2)
    CodeforcesRound#843(Div.2)本次脑袋不大灵光,一方面可能是怕掉分。另一方面就是交的人实在是太少了,导致我一直不敢交,其实这场cf没有我想象中那么难,甚至来说我一直是......
  • leetcode_数据结构_入门_1. 两数之和
    1.两数之和问题给定一个整数数组nums 和一个整数目标值target,请在该数组中找出和为目标值target的那 两个整数,并返回它们的数组下标。分析可以假设每种输入......