Android creates a comment template by itself. As a programmer, it is important not only to have the ability to write code, but to develop a good writing habit. Today, we will give you a detailed description of how to create a comment template. You can also manually annotate the information for each class and method, but this is complicated. Why don't we create a comment template manually?
First, we need to compile a template xml file (codetemplates. xml)
2. Now we will write the content information of the main comments to the xml file, and I will directly paste the xml Information I used.
/**
* @ Description:
* @ Method Name: $ {enclosing_method}
* $ {Tags}
* @ Creator: $ {user}
* @ Creation time: $ {date }$ {time}
* @ Modifier: $ {user}
* @ Modification time: $ {date }$ {time}
* @ Modify remarks:
* @ Throws
*/ /**
* @ Description:
* @ Method Name: $ {enclosing_method}
* $ {Tags}
* @ Return type $ {return_type}
* @ Creator $ {user}
* @ Creation time $ {date }$ {time}
* @ Modifier $ {user}
* @ Modification time $ {date }$ {time}
* @ Modify remarks
* @ Since
* @ Throws
*/ /**
* & Lt; p & gt; Title: & lt;/p & gt;
* & Lt; p & gt; Description: & lt;/p & gt;
* $ {Tags}
*/ /**
* @ Param $ {param} $ {bare_field_name}
*/ /**
* $ {Tags}
* $ {See_to_target}
*/ /**
* @ Return $ {bare_field_name}
*/ /**
* @ Class description:
* @ Project name: $ {project_name}
* @ Package name: $ {package_name}
* @ Class Name: $ {type_name}
* @ Creator: $ {user}
* @ Creation time: $ {date }$ {time}
* @ Modifier: $ {user}
* @ Modification time: $ {date }$ {time}
* @ Modify remarks:
* @ Version v1.0
* @ See [nothing]
* @ Bug [nothing]
* @ Copyright go3c
* @ Mail * @ qq.com
*/ /**
* @ Title: $ {file_name}
* @ Package name: $ {package_name}
* @ Function Description: $ {todo}
* @ Author: $ {user}
* @ Creation time: $ {date }$ {time}
* @ Version v1.0
*/ /**
* @ Field: $ {field}
* @ Function description:
* @ Creator: $ {user}
* @ Creation time: $ {date }$ {time}
*/
3. How can we use this compiled xml file in eclipse? Now let me explain it to you! Window --> Preferences --> Java --> Code Style --> Code Templates --> Comments --> Import --> select codetemplates. xml --> OK to add the email address. The Creator name can be added to eclipse. ini in the eclipse directory-Duser. name = "whateveryouwant ".
4. How can we quickly use the annotation module information we have written in eclipse? When adding a comment, enter/** in the class name and press enter to automatically generate the following format comment:
/**
*
* @ Class description:
* @ Project name:
* @ Package name:
* @ Class Name: AppDao
* @ Creator:
* @ Creation Time: 10:32:30 AM
* @ Modifier:
* @ Modification time: 10:32:30 AM
* @ Modify remarks:
* @ Version v1.0
* @ See [nothing]
* @ Bug [nothing]
* @ Copyright
* @ Mail */
Enter/** in the method name and press enter to automatically generate the following format comment:
/**
*
* @ Description:
* @ Method Name: UpdatePlayerHistory
* @ Param db
* @ Param item
* @ Return
* @ Return type int
* @ Creator
* @ Creation Time: 10:22:36 AM
* @ Modifier
* @ Modification time: 10:22:36 AM
* @ Modify remarks
* @ Since
* @ Throws
*/
You must manually enter the description.
Note: This article is original. Please respect the individual's Labor achievements! Thank you!