当项目完成了之后,为了方便以后的维护,知道各个接口或者类的功能,想把整个项目中的注释导出来,做成api文件。
一、 注释:
给所有需要的类和方法以及属性加上注释。
一般规范:
(1)类的注释:
/**
*XXX
*@author XXX
*@version XXX
**/
(2)方法的注释:
/*
*XXXXX
*/
(3)属性的注释:
//XXXXX
二、利用myeclipse自带的功能导出
1,右键选中项目
2,选中导出“export”
3,选中java下的javadoc
4,configure :一般在jdk的bin目录下可以找到javadoc.exe,选中需要导出的项目并且选择导出的路径
5,点击next,然后配置需要引入的jar包,默认是不选,然后next
6,然后进入如下界面,在这个界面可以配置一些自己的tag以及导出的编码
@author、@version这些标签都是java自带的标签,也可以定义自己的标签,语法: -tag <name>:<locations>:<header> 指定单个参数定制标记 ,
其中name属性就是你自定义标记的名称,locations官方上有以下选项:
Placement of tags - The Xaoptcmf part of the argument determines where in the source code the tag is allowed to be placed, and whether the tag can be disabled (using X). You can supply either a, to allow the tag in all places, or any combination of the other letters:
- X (disable tag)
- a (all)
- o (overview)
- p (packages)
- t (types, that is classes and interfaces)
- c (constructors)
- m (methods)
- f (fields)
例子: -tag date:a:"date" ,定义了这个之后,java类中的@date标签javadoc.exe就能够解析这个标签了,导出的时候不会抛出错误。
此外,如果项目中使用UTF-8编码,在导出javadoc的时候一定要设置编码,因为默认的是用GBK的编码格式。如果不设置的话,会有乱码,然后就导出失败。
-encoding UTF-8 -charset UTF-8
7,然后finish就可以了。