java doc说明书_JAVADOC 常见使用方法 帮助文档
我們知道Java中有三種注釋語句:1.//用于單行注釋。
2./*...*/用于多行注釋,從/*開始,到*/結(jié)束,不能嵌套。3./**...*/則是為支持jdk工具javadoc.exe而特有的注釋語句。
javadoc工具能從java源文件中讀取第三種注釋,并能識別注釋中用@標(biāo)識的一些特殊變量(見表),制作成Html格式的類說明文檔。 javadoc不但能對一個java源文件生成注釋文檔,而且能對目錄和包生成交叉鏈接的html格式的類說明文檔,十分方便。
注釋中可以出現(xiàn)的關(guān)鍵字,以@開頭:
@author 作者名
@version 版本標(biāo)識
@parameter 參數(shù)名及其意義
@since 最早出現(xiàn)的JDK版本
@return返回值
@throws異常類及拋出條件
@deprecated 引起不推薦使用的警告
@see 交叉參考
下面是javadoc.exe的用法
C:\java>javadoc -help
C:\java>javadoc -help
usage: javadoc [options] [packagenames] [sourcefiles] [classnames] [@files]-overview Read overview documentation from HTML file-public Show only publicclasses and members-protected Show protected/public classes and members (default)-package Show package/protected/publicclasses and members-privateShow all classes and members-help Display command line options and exit-doclet Generate output via alternate doclet-docletpath Specify where to find doclet classfiles-sourcepath Specify where to find source files-classpath Specify where to find user classfiles-exclude Specify a list of packages to exclude-subpackages Specify subpackages to recursively load-breakiterator Compute 1st sentence with BreakIterator-bootclasspath Override location of class files loaded by the bootstrap classloader-source Provide source compatibility with specified release-extdirs Override location of installed extensions-verbose Output messages about what Javadoc is doing-locale Locale to be used, e.g. en_US or en_US_WIN-encoding Source file encoding name-J Pass directly to the runtime system
Provided by Standard doclet:-d Destination directory foroutput files-use Create class and packageusage pages-version Include @version paragraphs-author Include @author paragraphs-docfilessubdirs Recursively copy doc-file subdirectories-splitindex Split index into one file per letter-windowtitle Browser window title forthe documenation-doctitle Include title forthe overview page-header Include header text foreach page-footer Include footer text foreach page-bottom Include bottom text foreach page-link Create links to javadoc output at
-linkoffline Link to docs at using package list at
-excludedocfilessubdir :.. Exclude any doc-files subdirectories with given name.-group :.. Group specified packages together in overviewpage-nocomment Supress description and tags, generate only declarations.-nodeprecated Do not include @deprecated information-noqualifier ::... Exclude the list of qualifiers from the output.-nosince Do not include @since information-nodeprecatedlist Do not generate deprecated list-notree Do not generate classhierarchy-noindex Do not generate index-nohelp Do not generate help link-nonavbar Do not generate navigation bar-quiet Do not display status messages to screen-serialwarn Generate warning about @serial tag-tag ::Specify single argument custom tags-taglet The fully qualified name of Taglet to register-tagletpath The path to Taglets-charset Charset for cross-platform viewing of generated documentation.-helpfile Include file that help link links to-linksource Generate source in HTML-stylesheetfile File to change style of the generated documentation-docencoding Output encoding name
C:\java>下面請看用javadoc生成的文檔(請點擊本頁上面的觀看演示鏈接)
生成文檔:
C:\java>javadoc JavadocDemo.java
Loading source file JavadocDemo.java...
Constructing Javadoc information...
Standard Doclet version1.4.2_03
Generating constant-values.html...
Building treeforall the packages and classes...
Building indexforall the packages and classes...
Generating overview-tree.html...
Generating index-all.html...
Generating deprecated-list.html...
Building indexforall classes...
Generating allclasses-frame.html...
Generating allclasses-noframe.html...
Generating index.html...
Generating packages.html...
Generating JavadocDemo.html...
JavadocDemo.java:11: warning -Tag @see: reference not found: javax.swing.Japplet
Generating serialized-form.html...
Generatingpackage-list...
Generating help-doc.html...
Generating stylesheet.css...1warning
C:\java>附源文件:import java.applet.*;import java.awt.*;import java.awt.event.*;/***JavadocDemo.java,一個顯示JavaDoc注釋的Applet
*
注意這只是HelloApplet的一個帶注釋的版本
*@seejava.applet.Applet
*@seejavax.swing.Japplet*/
public class JavadocDemo extendsApplet{/**init()是一個Applet方法,由瀏覽器調(diào)用進(jìn)行初始化
* 只調(diào)用一次
*@return無*/
public voidinit(){//創(chuàng)建并添加一個按鈕//其它什么也不做
Button b;
b=new Button("Hello");
add(b);
show();
}/**paint() 是一個AWT組件方法,在組件要繪制時調(diào)用,只
* 是在Applet的窗口中畫帶色的方框。
* 參數(shù) g一個java.awt.Graphics
* 用在所有繪制方法中*/
public voidpaint(Graphics g){int w=getSize().width,h=getSize().height;
g.setColor(Color.yellow);
g.fillRect(0,0,w/2,h);
g.setColor(Color.green);
g.fillRect(w/2,0,w,h);
g.setColor(Color.black);
g.drawString("Welcome to Java",50,50);
}/**show()用于使組件可見,此方法在
* JDK1.1中被歸入不推薦使用
*@since1.0
*deprecated換用setVisible(true)*/
public voidshow(){//由于覆蓋了show(),此applet 不能顯示
}/**Applet必須有一個公共的無參數(shù)構(gòu)造方法
*@throwsjava.lang.IllegalArgumentException*/
publicJavadocDemo(){if(new java.util.Date().getDay()==0){throw new IllegalArgumentException("Never on a Sunday");
}
}
}
總結(jié)
以上是生活随笔為你收集整理的java doc说明书_JAVADOC 常见使用方法 帮助文档的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java不同网址提示过期_使用histo
- 下一篇: java所有的质因数_Java实现分解任