使用source insight 宏来插入doxygen可处理的注释

宏文件如下。



设置快捷键后,双击高亮要注释的内容,使用快捷键触发即可。



可自动识别

普通:在头部添加

宏:在末尾添加注释

变量:在末尾添加

函数:在头部添加,并自动识别函数个数

类:在头部添加



代码如下:保存为m.em即可加入source insight



macro insert_func_header_comment()
{
hbuf = GetCurrentBuf()
if( hbuf == 0 ) stop

// Get current time
szTime = GetSysTime(1)
Day = szTime.Day
Month = szTime.Month
Year = szTime.Year

chTab = CharFromAscii(9)
chComma = CharFromAscii(44)

ln = GetBufLnCur( hbuf )
start_ln = ln;
symbol = GetCurSymbol()
if( symbol == nil )
{//没有找到符号
InsBufLine(hbuf, ln, "")
SetBufIns(hbuf, start_ln, 10)
stop
}

text = GetBufLine( hbuf, ln )
slen = strlen(text)

sbi = GetSymbolLocation( symbol )
if( sbi == nil )
{//无法得到符号记录,直接加一个简单记录了事
PutBufLine( hbuf, ln, cat(text," //!< " )
SetBufIns( hbuf, ln, slen + 6)
stop
}

if( sbi.Type == "Function" || sbi.Type == "Method" || sbi.Type == "Function Prototype" )
{// function
ich = 0
while( text[ich] == " " || text[ich] == chTab )
{
ich = ich + 1
}
szPrefix = strmid(text, 0, ich)
InsBufLine(hbuf, ln, cat( szPrefix, ""))
SetBufIns(hbuf, start_ln, strlen(szPrefix) + 10)
}
else if( sbi.Type == "Class" )
{// class
if( (start_ln == sbi.lnFirst) )
{//整个类注释
InsBufLine(hbuf, ln, "")
SetBufIns(hbuf, start_ln, 10)
}
else
{//类成员
PutBufLine( hbuf, ln, cat(text," //!< " )
SetBufIns( hbuf, ln, slen + 6)
}
}
else if( sbi.Type == "Structure" )
{// struct
if( (start_ln == sbi.lnFirst) )
{//整个结构体注释
InsBufLine(hbuf, ln, "")
SetBufIns(hbuf, start_ln, 10)
}
else
{//结构体成员
PutBufLine( hbuf, ln, cat(text," //!< " )
SetBufIns( hbuf, ln, slen + 6)
}
}
else if( sbi.Type == "Constant" )
{// macro
PutBufLine( hbuf, ln, cat(text," //!< " )
SetBufIns( hbuf, ln, slen + 6)
}
else if( sbi.Type == "Variable" )
{// variable
PutBufLine( hbuf, ln, cat(text," //!< " )
SetBufIns( hbuf, ln, slen + 6)
}

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值