Android代碼注釋模版
一、注釋模版的內(nèi)容 代碼注釋生成文檔,所以,部分注釋內(nèi)容需要用到html標(biāo)簽排版內(nèi)容以達(dá)到代碼美觀的目的,常用的
有等,Android studio 在 file菜單中選擇settings 搜索File and Code Templates,在右側(cè)菜單中選擇不同的代碼使用場(chǎng)景并編輯為需要的模版,在生成注釋時(shí)就可以生成自己想要的注釋
二、注釋代碼腳本編寫(xiě)
生成代碼模版時(shí),需要用到默認(rèn)的生成內(nèi)容,例如,將@author的默認(rèn)內(nèi)容設(shè)定為自己的用戶名,方法一、直接配置內(nèi)容 或者配置內(nèi)容為 USERNAME時(shí)間為{DATE} 、YEAR、{ORGANIZATION_NAME}
三、通用注釋模版
1.文件(Files)注釋標(biāo)簽:
/**
* All rights Reserved, Designed By Android_Robot
* @Title: filename?@Package{package_name}
* @Description: todo(用一句話描述該文件做什么)?@author:AndroidRobot?@date:{date} ${time}
* @version V1.0
*/
2.類型(Types)注釋標(biāo)簽(類的注釋):
/**
* @ClassName: typename?@Description:{todo}(這里用一句話描述這個(gè)類的作用)
* @author: Android_Robot
* @date: date{time}
*
* ${tags}
*/
3.字段(Fields)注釋標(biāo)簽:
/**
* @Fields field:{todo}(用一句話描述這個(gè)變量表示什么)
*/
4.構(gòu)造函數(shù)標(biāo)簽:
/**
* @Title: enclosingtype?@Description:{todo}(這里用一句話描述這個(gè)方法的作用)
* @param: ${tags}
* @throws
*/
5.方法(Methods)標(biāo)簽:
/**
* @Title: enclosingmethod?@Description:{todo}(這里用一句話描述這個(gè)方法的作用)
* @param: tags?@return:{return_type}
* @throws
*/
6.覆蓋方法(Overriding Methods)標(biāo)簽:
/**
*
Title: ${enclosing_method}
*
Description:
* tags?{see_to_overridden}
*/
7.代表方法(Delegate Methods)標(biāo)簽:
/**
* tags?{see_to_target}
*/
8.getter方法標(biāo)簽:
/**
* @Title: enclosingmethod?@Description:pleasewriteyourdescription?@return:{field_type}
*/
9.setter方法標(biāo)簽:
/**
* @Title: enclosingmethod?@Description:pleasewriteyourdescription?@return:{field_type}
*/