Java 9 HTML5 Javadoc

Javadoc is the tool that can generate documentation for API in HTML format. In previous version of JDK, it’s HTML 4.01 – an old standard. JDK 9 Javadoc now supports to generate HTML5 markup, improves search capability and Doclint.

I. HTML5 Javadoc
1. Generating

Assume that we have 2 classes in com.javasampleapproach.html5doc package:

To generate HTML Javadoc, we run this command:

With:
E:\Eclipse Java 9\Java9HTML5Javadoc\src is the path of src folder of our project.
E:\home\html is the foler that we wanna generate site source for Java Documentation.

Open view-source of the page, it is indicative of HTML4.01:
html5-javadoc-html4

In JDK 9 which supports HTML5, we just need to add -html5 parameter:

html5-javadoc-generate

This is how the site looks like:
html5-javadoc-index-all

And the source code indicates that it is in HTML5 format:
html5-javadoc-html5

We can see structural HTML5 elements such as header, nav
html5-javadoc-html5-elements

2. Searching

A search box is available on the site that can be used to search for program elements, tagged words and phrases within the documentation. The search functionality is implemented locally and not rely on any server-side computational resources.

We can search for:
– declared names of modules
– packages
– types
– members
html5-javadoc-search

II. -Xdoclint Feature Improvements

-Xdoclint enables recommended checks for issues in Javadoc comments: bad references, lack of accessibility, missing comments, syntax error and missing HTML tags. By default, -Xdoclint is enabled. We can disable it by -Xdoclint:none.

Some ways to use -Xdoclint:

  • -Xdoclint:group: enables group
  • -Xdoclint:all: enables all
  • -Xdoclint:all,-group: enables all except group
  • group could be one or more values: accessibility, html, missing, reference, syntax.

    For example, if we create an error: @return to @retur from comment of runAPITest() method in JavaSampleAPI.java, we can get a recommended check like this:
    html5-javadoc-xdoclint


    Related Posts



    Got Something To Say:

    Your email address will not be published. Required fields are marked *

    *