沈云峰
发布于 2023-04-18 / 25 阅读 / 0 评论 / 0 点赞

代码注释规范设置

1.类文件注释

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")

public class ${NAME} {
}

/**
 * Filename:    ${NAME}
 * Description: 
 * Copyright:   Copyright (c) 2023-2073 All Rights Reserved.
 * Company:     Armor Technology Co., Ltd.
 * @author:     shenyunfeng
 * @version:    1.0
 * Create at:   ${DATE} ${TIME} 
 *  
 * Modification History:  
 * Date         Author      Version     Description  
 * ------------------------------------------------------------------  
 * ${DATE}      shenyunfeng      1.0         1.0 Version  
 *
 */

注:请根据各自情况自行修改各属性

2.方法注释

*
 * @description
 $param$ 
 *
 $return$ 
 * <br>-----------------------------------------------------<br>
 *
 * @author: shenyunfeng 
 * @date: $date$ $time$
 */

设置参数表达式

param

groovyScript("def result = '';def params = \"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {if(params[i] != '')result+='* @param ' + params[i] + ' ' +((i < params.size() - 1) ? '\\r\\n ' : '')}; return result == '' ? null : result", methodParameters()) 

return

groovyScript("def returnType = \"${_1}\"; def result ='';if(returnType=='null'||returnType=='void'){result += '*';}else{result += '* @return ';cls = returnType.split('<');for(i = 0; i < cls.size(); i++){temp = cls[i].tokenize('.');result += temp[temp.size() - 1] + ((i < cls.size() - 1) ? '<' : '');};return result + ' ';}", methodReturnType()); 

date 和 time见上图


评论