Java学习者论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

恭喜Java学习者论坛(https://www.javaxxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,购买链接:点击进入购买VIP会员
JAVA高级面试进阶视频教程Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程

Go语言视频零基础入门到精通

Java架构师3期(课件+源码)

Java开发全终端实战租房项目视频教程

SpringBoot2.X入门到高级使用教程

大数据培训第六期全套视频教程

深度学习(CNN RNN GAN)算法原理

Java亿级流量电商系统视频教程

互联网架构师视频教程

年薪50万Spark2.0从入门到精通

年薪50万!人工智能学习路线教程

年薪50万!大数据从入门到精通学习路线年薪50万!机器学习入门到精通视频教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程 MySQL入门到精通教程
查看: 274|回复: 0

[Java基础知识]javadoc的用法

[复制链接]
  • TA的每日心情
    开心
    2021-3-12 23:18
  • 签到天数: 2 天

    [LV.1]初来乍到

    发表于 2014-10-1 02:49:53 | 显示全部楼层 |阅读模式
    我们知道java中有三种注释语句:
    1.//用于单行注释。
    2./*...*/用于多行注释,从/*开始,到*/结束,不能嵌套。
    3./**...*/则是为支持jdk工具javadoc.exe而特有的注释语句。
        javadoc工具能从java源文件中读取第三种注释,并能识别注释中用@标识的一些特殊变量(见表),制作成HTML格式的类说明文档。javadoc不但能对一个java源文件生成注释文档,而且能对目录和包生成交叉链接的html格式的类说明文档,十分方便。

      

      
      注释中可以出现的关键字,以@开头:
    @author        作者名
    @version       版本标识
    @parameter     参数名及其意义
    @since         最早出现的JDK版本
    @return        返回值
    @throws        异常类及抛出条件
    @deprecated    引起不推荐使用的警告
    @see           交叉参考

    下面是javadoc.exe的用法

    C:java>javadoc -help


    C:java>javadoc -help  
      
       
       
       

       
      
      
    usage: javadoc [options] [packagenames] [sourcefiles] [classnames] [@files]
    -overview <file>          Read overview documentation from HTML file
    -public                   Show only public classes and members
    -protected                Show protected/public classes and members (default)
    -package                  Show package/protected/public classes and members
    -private                  Show all classes and members
    -help                     Display command line options and exit
    -doclet <class>           Generate output via alternate doclet
    -docletpath <path>        Specify where to find doclet class files
    -sourcepath <pathlist>    Specify where to find source files
    -classpath <pathlist>     Specify where to find user class files
    -exclude <pkglist>        Specify a list of packages to exclude
    -subpackages <subpkglist> Specify subpackages to recursively load
    -breakiterator            Compute 1st sentence with BreakIterator
    -bootclasspath <pathlist> Override location of class files loaded by the bootstrap class loader
    -source <release>         Provide source compatibility with specified release
    -extdirs <dirlist>        Override location of installed extensions
    -verbose                  Output messages about what Javadoc is doing
    -locale <name>            Locale to be used, e.g. en_US or en_US_WIN
    -encoding <name>          Source file encoding name
    -J<flag>                  Pass <flag> directly to the runtime system

    Provided by Standard doclet:
    -d <directory>                    Destination directory for output files
    -use                              Create class and package usage pages
    -version                          Include @version paragraphs
    -author                           Include @author paragraphs
    -docfilessubdirs                  Recursively copy doc-file subdirectories
    -splitindex                       Split index into one file per letter
    -windowtitle <text>               Browser window title for the documenation
    -doctitle <html-code>             Include title for the overview page
    -header <html-code>               Include header text for each page
    -footer <html-code>               Include footer text for each page
    -bottom <html-code>               Include bottom text for each page
    -link <url>                       Create links to javadoc output at <url>
    -linkoffline <url> <url2>         Link to docs at <url> using package list at <url2>
    -excludedocfilessubdir <name1>:.. Exclude any doc-files subdirectories with given name.
    -group <name> <p1>:<p2>..         Group specified packages together in overviewpage
    -nocomment                        Supress description and tags, generate only declarations.
    -nodeprecated                     Do not include @deprecated information
    -noqualifier <name1>:<name2>:...  Exclude the list of qualifiers from the output.
    -nosince                          Do not include @since information
    -nodeprecatedlist                 Do not generate deprecated list
    -notree                           Do not generate class hierarchy
    -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 <name>:<locations>:<header>  Specify single argument custom tags
    -taglet                           The fully qualified name of Taglet to register

    -tagletpath                       The path to Taglets
    -charset <charset>                Charset for cross-platform viewing of generated documentation.
    -helpfile <file>                  Include file that help link links to
    -linksource                       Generate source in HTML
    -stylesheetfile <path>            File to change style of the generated documentation
    -docencoding <name>               Output encoding name

    C:java>
    下面请看用javadoc生成的文档(请点击本页上面的观看演示链接)
    生成文档:

    C:java>javadoc  JavadocDemo.java
    Loading source file JavadocDemo.java...
    Constructing Javadoc information...
    Standard Doclet version 1.4.2_03
    Generating constant-values.html...
    Building tree for all the packages and classes...
    Building index for all the packages and classes...
    Generating overview-tree.html...
    Generating index-all.html...
    Generating deprecated-list.html...
    Building index for all 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...
    Generating package-list...
    Generating help-doc.html...
    Generating stylesheet.css...
    1 warning

    C:java>
    附源文件:
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    /**
       *JavadocDemo.java,一个显示JavaDoc注释的Applet
       *<p>注意这只是HelloApplet的一个带注释的版本
       *@see java.applet.Applet
       *@see javax.swing.Japplet
       */

      public class JavadocDemo extends Applet{

        /** init()是一个Applet方法,由浏览器调用进行初始化
          * 只调用一次
          * @return 无
          */
        public void init(){
             //创建并添加一个按钮
             //其它什么也不做
             Button b;
             b=new Button("Hello");
             add(b);
             show();
        }

        /** paint() 是一个AWT组件方法,在组件要绘制时调用,只
          * 是在Applet的窗口中画带色的方框。
          * 参数 g一个java.awt.Graphics
          * 用在所有绘制方法中
          */

        public void paint(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中被归入不推荐使用
          *@since 1.0
          *deprecated换用setVisible(true)
          */

        public void show(){
             //由于覆盖了show(),此applet 不能显示
        }

        /** Applet必须有一个公共的无参数构造方法
          *@throws java.lang.IllegalArgumentException
          */

        public JavadocDemo(){
           if(new java.util.Date().getDay()==0){
                 throw new IllegalArgumentException("Never on a Sunday");
            }
        }
    }
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|Java学习者论坛 ( 声明:本站资料整理自互联网,用于Java学习者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-4-28 00:34 , Processed in 0.469763 second(s), 48 queries .

    Powered by Discuz! X3.4

    © 2001-2017 Comsenz Inc.

    快速回复 返回顶部 返回列表