Core Java

Doclava: Custom Javadoc Doclet from Google

Doclava is a custom Javadoc Doclet from Google, used by Google Guice (see their slight cooler Javadocs). Doclava uses JSilver as its templating engine, a pure-Java implementation of Clearsilver. I personally like the idea of Federated Documents to allow documentations to link and integrate to each other on open projects.

Here are the main differences between Doclava and the standard Doclet:

  • Refreshed look and feel, including search capabilities.
  • Embeds versioning information in the documentation.
  • Uses a templating engine for user customizations.
  • Throw build errors for things that can easily be caught, like @param tags that don’t match the parameter names.
  • Ability to include snippets of code from real source code
  • Federate documentation between multiple sites.
  • Ability to embed javadocs in a larger web page.

Using Doclava with Javadoc

-doclet -docletpath ${jar.file}

Using Doclava with Ant

  <target name="doclava" depends="jar">
    <javadoc packagenames="*"
      <doclet name="">
        <param name="-stubs" value="build/stubs" />
        <param name="-hdf"/> <param name=""/> <param name="Doclava"/>
        <!-- versioning -->
        <param name="-since"/> <param name="doclava/previous.xml"/> <param name="v1" />
        <param name="-apiversion" value="v2"/>
        <!-- federation -->
        <param name="-federate" /><param name="JDK"/>
        <param name=""/>
        <param name="-federationxml"/><param name="JDK"/>
        <param name=""/>

Using Doclava with Maven

            | bootclasspath required by Sun's JVM
             -federate JDK
             -federationxml JDK
             -hdf "${}"
             -d ${}/apidocs
            | Apple's JVM sometimes requires more memory

Improved Tags

Doclava supports a few extra tags such as @undeprecate (pretty self-explanatory), @hide (remove from the documentation), @include $filePath (includes text from file), @sample (includes sample from file) and a few different ones. Please see the complete list here.


And if you are tired of the old Javadoc look and feel, you can customize the output of Doclava. For more information click here.

Reference: Doclava: Custom Javadoc Doclet from Google from our JCG partner Felipe Oliveira.

Related Articles:

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Back to top button