📜  Java 9-改进的JavaDocs

📅  最后修改于: 2020-11-15 03:14:00             🧑  作者: Mango


可以使用javadoc工具生成Java文档。当前,它以html 4.0格式生成文档。在Java 9中,我们可以通过在命令行参数中使用-html5选项来生成html 5格式的文档。

旧样式的Java文档

考虑以下C:/ JAVA文件夹中的代码。

测试器

/**
  * @author MahKumar
  * @version 0.1
*/
public class Tester {
   /**
      * Default method to be run to print 
      * 

Hello world

* @param args command line arguments */ public static void main(String []args) { System.out.println("Hello World"); } }

现在运行jdk 7的javadoc工具生成文档。

C:\JAVA>javadoc -d C:/JAVA Tester.java
Loading source file tester.java...
Constructing Javadoc information...
Standard Doclet version 1.7.0_21
Building tree for all the packages and classes...
Generating C:\JAVA\Tester.html...
Generating C:\JAVA\package-frame.html...
Generating C:\JAVA\package-summary.html...
Generating C:\JAVA\package-tree.html...
Generating C:\JAVA\constant-values.html...
Building index for all the packages and classes...
Generating C:\JAVA\overview-tree.html...
Generating C:\JAVA\index-all.html...
Generating C:\JAVA\deprecated-list.html...
Building index for all classes...
Generating C:\JAVA\allclasses-frame.html...
Generating C:\JAVA\allclasses-noframe.html...
Generating C:\JAVA\index.html...
Generating C:\JAVA\help-doc.html...

它将在C:/ JAVA目录中创建Java文档页面,您将看到以下输出。

javadoc输出

带有Search和HTML5支持的新Java文档

使用-html5标志运行jdk 9的javadoc工具以生成新类型的文档。

C:\JAVA> javadoc -d C:/JAVA -html5 Tester.java
Loading source file Tester.java...
Constructing Javadoc information...
Standard Doclet version 9.0.1
Building tree for all the packages and classes...
Generating C:\JAVA\Tester.html...
Generating C:\JAVA\package-frame.html...
Generating C:\JAVA\package-summary.html...
Generating C:\JAVA\package-tree.html...
Generating C:\JAVA\constant-values.html...
Building index for all the packages and classes...
Generating C:\JAVA\overview-tree.html...
Generating C:\JAVA\index-all.html...
Generating C:\JAVA\deprecated-list.html...
Building index for all classes...
Generating C:\JAVA\allclasses-frame.html...
Generating C:\JAVA\allclasses-frame.html...
Generating C:\JAVA\allclasses-noframe.html...
Generating C:\JAVA\allclasses-noframe.html...
Generating C:\JAVA\index.html...
Generating C:\JAVA\help-doc.html...

它将在D:/ test目录中创建更新的Java文档页面,您将看到以下输出。

Java 9中的javadoc输出