在VC中定制Doxygen注释宏

感谢曾发明同学

 

1 参照vc自带的sample.dsm生成文档yymacro.dsm;

2 编辑yymacro.dsm内容,添加如下三个宏:

       A)

‘生成Doxygen样式的函数注释

YYAddDoxygenFunctionDescription()

对应注释为:

       /**

        * Func1 declaration

        * @param int a input1 a

        * @param int b input2 b

        * @see TestMe()

        * @return int

 */

对应按钮为:

Ctrl+shift+f

 

       B)

‘生成doxygen样式的公开变量的注释

YYAddDoxygenValDescription ()

对应注释为:

/**< . . */

对应按钮为:

Ctrl+shift+v

       C)

‘生成doxygen样式的一般通用的注释

YYAddDoxygenCommenDescription ()

对应注释为:

/**

       *

 */

对应按钮为:

Ctrl+shift+c

3 保存yymacro.dsm,并添加该宏文件到sample.dsm所在目录中。

4 参照msdn中” To assign a macro to a toolbar button”,” To assign a macro to a key sequence”映射对应宏到按钮和菜单。

 

5 附录:

A) yymacro.dsm

‘——————————————————————————

‘FILE DESCRIPTION: 杨勇定制的宏,内含doxygen注释宏等。

‘——————————————————————————

 

‘辅助函数

‘Strips the leading tab spaces.

Function YYStripTabs (ByVal MyStr)

       Do While InStr(MyStr, vbTab) <> 0

              MyStr = Right(MyStr, Len(MyStr) – InStr(MyStr, vbTab))

       Loop

       YYStripTabs = Trim(MyStr)

End Function

 

‘生成Doxygen样式的函数注释

Sub YYAddDoxygenFunctionDescription()

‘DESCRIPTION: AddDoxygenFunctionDescription

‘DESCRIPTION: Creates a comment block for the currently selected C/C++ function prototype

 

       ‘Throughout this file, ActiveDocument.Selection is used in place

       ‘of ActiveDocument.Selection.Text.  The two are equivalent, and can

       ‘be used interchangeably. The reason for the equivalence is that

       ‘Text is regarded as the default property to use. All uses of

       ‘ActiveDocument.Selection without any other property default to the Text

       ‘property.

       ‘

       if ActiveDocument.Language = dsCPP Then

              Header = YYStripTabs(Trim(ActiveDocument.Selection))

 

              ‘Get the function return type.

              ‘RetTp 返回类型

              if Header <> "" then

                     Reti = InStr(Header, " ")

                     Loc = InStr(Header, "(")

                     if Reti < Loc Then

                       RetTp = Left(Header, Reti)

                       Header = Right(Header, Len(Header) – Reti)

                     End If

 

                     ‘Get the function name.

                     ‘fcName 函数名城

                     Loc = InStr(Header, "(") – 1

                     Loc2 = InStr(Header, ")")

                     if Loc > 0 And Loc2 > 0 then ‘make sure there is a ‘(‘ and a ‘)’

                            fcName = Left(Header, Loc)

                            Header = Right(Header, Len(Header) – Len(fcName))

 

                            ‘Do we have storage type on the return type?

                            Trim (fcName)

                            If InStr(fcName," ") <> 0 Then

                                   retTp = retTp + Left(fcName,InStr (fcName," "))

                                   fcName = Right(fcName, Len(fcName) – InStr(fcName," "))

                            End If

 

                            ‘Get the function parameters.

                            iPrm = 0

                            iPrmA = 0

                            prms = Header

 

                            ‘Count the number of parameters.

                            Do While InStr(prms, ",") <> 0

                                   iPrm = iPrm + 1

                                   prms = Right(prms, Len(prms) – InStr(prms, ","))

                            Loop

                           

                            ‘Store the parameter list in the array.

                            If iPrm > 0 Then  ‘ If multiple params.

                                   iPrm = iPrm + 1

                                   iPrmA = iPrm

                                   Redim ParamArr(iPrm)

                                   Do While InStr(header, ",") <> 0

                                          ParamArr(iPrm) = Left(Header, InStr (Header, ",") – 1)

                                          ‘Remove brace from first parameter.

                                          If InStr(ParamArr(iPrm), " (") <> 0 Then

                                                 ParamArr(iPrm) = Right(ParamArr(iPrm), _

                                                               Len(ParamArr(iPrm))-InStr(ParamArr(iPrm)," ("))

                                                 Trim(ParamArr(iPrm))

                                          End If

                                          Header = Right(Header, Len(Header) – InStr(Header,","))

                                          iPrm = iPrm – 1

                                          Loop

                                   ParamArr(iPrm) = Header

                                   ‘Remove trailing brace from last parameter.

                                   If InStr(ParamArr(iPrm), ")") <> 0 Then

                                          ParamArr(iPrm) = Left(ParamArr(iPrm), _

                                                        InStr(ParamArr(iPrm), ")") – 1)

                                          Trim(ParamArr(iPrm))

                                   End If

                            Else ‘Possibly one param.

                                   Redim ParamArr(1)

                                   Header = Right(Header, Len(Header) – 1) ‘ Strip the first brace.

                                   Trim(Header)

                                   ParamArr(1) = YYStripTabs(Header)

                                   If InStr(ParamArr(1), ")") <> 1 Then

                                          ParamArr(1) = Left(ParamArr(1), InStr(ParamArr(1), ")") – 1)

                                          Trim(ParamArr(1))

                                          iPrmA = 1

                                   End If

                            End If

 

                            ‘Position the cursor one line above the selected text.

                            ActiveDocument.Selection.LineUp

                            ActiveDocument.Selection.LineDown

                            ActiveDocument.Selection.StartOfLine

                            ActiveDocument.Selection = vbLf

 

                            ‘声称Doxygen样注释文档

                            Descr = vbTab + "/**" + _                                                    

                                          vbLf + vbTab + " * " + fcName + _

                                          vbLf

                           

                            ‘Print the parameter list.

                            Last = iPrmA

                            Do While iPrmA <> 0

                                   ‘Remove a line feed from any of the arguments.

                                   If InStr(ParamArr(iPrmA), vbLf) <> 0 Then

                                          ParamArr(iPrmA) = Right(ParamArr(iPrmA), _

                                                        (Len(ParamArr(iPrmA)) – _

                                                        InStr(ParamArr(iPrmA), vbLf)))

                                          Trim(ParamArr(iPrmA))

                                   End If

                                   ParamArr(iPrmA) = YYStripTabs(ParamArr(iPrmA))

                                   ‘If there are 2+ parameters, the first parameter will

                                   ‘have a ‘(‘ prepended to it, remove it here:

                                   if iPrmA = Last AND Last <> 1 then

                                     ParamArr(iPrmA) = Right(ParamArr(iPrmA), _

                                                 Len(ParamArr(iPrmA)) – 1)

                                   End If

                                   Descr = Descr + _

                                                 vbTab + " * @param " + ParamArr(iPrmA) + _

                                                 vbLf

                                   iPrmA = iPrmA – 1

                            Loop

 

                            Descr = Descr + _

                                          vbTab + " * @return " + RetTp + _

                                          vbLf + vbTab + " */" + _

                                          vbLf

                            ActiveDocument.Selection = Descr

                     Else

                            MsgBox("It is possible that the function you are trying to"+_

                                          " work with has a syntax error.")

                     End if

              End If

       Else

              MsgBox("You need to have an active C/C++ document open"+ _

                            vbLF+"with the function prototype selected.")

       End If

End Sub

 

‘生成doxygen样式的公开变量的注释

Sub YYAddDoxygenValDescription ()

       if ActiveDocument.Language = dsCPP Then

              ActiveDocument.Selection = ActiveDocument.Selection + _

                                                               vbTab + "/**< . . */"                          

       End if

End Sub

 

‘生成doxygen样式的一般通用的注释

Sub YYAddDoxygenCommenDescription ()

       if ActiveDocument.Language = dsCPP Then

              ActiveDocument.Selection = "/** " + _

                                                               vbLf + " * " + _

                                                               vbLf + " */"

       End if

End Sub

 

 

B)测试文件

#ifndef __A__H

#define __A__H

 

#include <iostream>

 

/**

 *   class A’s declaration

 */

class A

{

public:

       enum TEnum

       {

              TVal1,           /**< enum value TVal1. */ 

              TVal2,           /**< enum value TVal2. */ 

              TVal3            /**< enum value TVal3. */ 

       };

 

       TEnum *enumPtr; /**< enum pointer. Details. */

       TEnum enumVar;  /**< enum variable. Details. */

 

       /**

        * Func1 declaration

        * @param int a input1 a

        * @param int b input2 b

        * @see TestMe()

        * @return int

        */

 

       int Func1(int a, int b);

 

 

       /**

        * TestMe

        * @param int a

        * @param const char *s

        * @return int

        */

       int TestMe(int a,const char *s);

 

 

       /**

        * TestAutoComment

        * @param int a param1 description

        * @param int b param2 description

        * @param char c param3 description

        * @return int ret description

        */

       int TestAutoComment(int a, int b, char c);

 

       int iA;     /**< iA1. iA’s Details1. */

                     /**< iA2. iA’s Details2. */

      

       /**

       * a public variable iB.

       * Details1.

       * Details2.

       */

       int iB;     /**< . . */

 

       int iC; /**< iC1 中文注释测试. iC’s Details1. */

                     /**< iC2. iC’s Details2. */

};

 

#endif//__A__H

时间: 2024-09-15 10:14:18

在VC中定制Doxygen注释宏的相关文章

VC中的TRACE宏

TRACE宏对于VC下程序调试来说是很有用的东西,有着类似printf的功能:该宏仅仅在程序的DEBUG版本中出现,当RELEASE的时候该宏就完全消失了,从而帮助你调式也在RELEASE的时候减少代码量. 使用非常简单,格式如下: TRACE("DDDDDDDDDDD"); TRACE("wewe%d",333); 同样还存在TRACE0,TRACE1,TRACE2...分别对应0,1,2..个参数 TRACE信息输出到VC IDE环境的输出窗口(该窗口是你编译项

VC 项目中可以使用的路径宏

原文地址:http://blog.csdn.net/collin1211/article/details/2483316 VC 项目中可以使用的路径宏: 宏 说明 $(RemoteMachine) 设置为"调试"属性页上"远程计算机"属性的值.有关更多信息,请参见更改用于 C/C++ 调试配置的项目设置. $(References) 以分号分隔的引用列表被添加到项目中. $(ConfigurationName) 当前项目配置的名称(例如"Debug&quo

在Visual C++中定制AppWizard (一)

第一部分 AppWizard及其工作原理 AppWizard即应用程序向导,它是Visual Studio开发环境中强大的编程工具之一,用它可以创建各种不同类型的程序.比如Win32应用.ATL.MFC应用等等.在Windows的术语中,向导(wizard)一词指得是一个应用程序,它的一个主要特点就是提供一系列对话框引导用户进行必要的选择来完成给定的任务.VC中的应用程序向导--AppWizard提供一系列特定工程类型对话框来让程序员定义各种类型的新工程.其中每一个对话框都显示一些用来指定工程类

VC中不同类型DLL及区别

1. DLL的概念可以向程序提供一些函数.变量或类. 静态链接库与动态链接库的区别:(1)静态链接库与动态链接库都是共享代码的方式.静态链接库把最后的指令都包含在最终生成的EXE文件中了:动态链接库不必被包含在最终EXE文件中,EXE文件执行时可以"动态"地引用和卸载这个与EXE独立的DLL文件.(2) 静态链接库中不能再包含其他的动态链接库或者静态库,而在动态链接库中还可以再包含其他的动态或静态链接库. DLL分类:1.Non-MFC DLL(非MFC动态库):不采用MFC类库结构,

VC++中利用MSXML解析XML文档

c++|xml 四.程序实现 下面通过一个具体的实例来说明在VC++中如何利用MSXML解析XML文档. (1)源XML文档(xmlfile.xml)如下: <?xml version="1.0" encoding="GB2312"?> <Device id="10041" name="设备1"> <Type>13</Type> <TypeName>保护</Ty

VB中定制DllRegisterServer、DllUnregisterServer

server VB中定制DllRegisterServer.DllUnregisterServer -阿鬼(heroyin) VB作为一种简单容易上手的语言,可以让开发者快速上手,开发速度快,效率高.但它过分的封装也给开发者带来诸多不便. 问题的由来最近本人在开发一个插件结构的项目中就遇到了一个麻烦,我的项目是采用COM架构,框架由DELPHI开发,插件为COM组件,插件可以由其他语言开发,当然也包括VB.每个插件必须注册为一个固定的组件类别(Categories).在其他语言如VC.DELPH

VC++中的自定义消息

在VC++中想加入自定义消息,以下方法可供参考 -- 1 首先定义消息:例如 define WM_MYMESSAGE (WM_USER+100) 2 在.H文件中,加入消息响应函数,如:LONG OnMyMessage(WPARAM w,LPARAM l); 该函数有规定的格式:LONG Function_Name(WPARAM w,LPARAM l); 3 加入消息响应宏 在响应该消息的类中,在消息响应块中, BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{

vc中使用SendMessage自定义消息函数

  这篇文章主要介绍了vc中使用SendMessage自定义消息函数的相关资料,需要的朋友可以参考下 SendMessage的基本结构如下: ? 1 2 3 4 5 6 SendMessage( HWND hWnd, //消息传递的目标窗口或线程的句柄. UINT Msg, //消息类别(这里可以是一些系统消息,也可以是自己定义,下文具体介绍,) WPARAM wParam, //参数1 (WPARAM 其实是与UINT是同种类型的, //在vc编译器中右键有个"转到WPARAM的定义"

c++-VC++中窗口过程函数的wParam和lParam区别??

问题描述 VC++中窗口过程函数的wParam和lParam区别?? VC++中窗口过程函数的wParam和lParam区别??是什么希望解析 解决方案 我要告诉你的是方法,怎么去自学,而不是结论: 看到 https://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx 这里(google 搜索wm_keydown msdn第一个结果) wParam The virtual-key code of the nonsystem key. S