Home » Java » Core Java » Doclava: Custom Javadoc Doclet from Google

About Felipe Oliveira

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 com.google.doclava.Doclava -docletpath ${jar.file}

Using Doclava with Ant

<project>
  ...
  <target name="doclava" depends="jar">
    <javadoc packagenames="com.google.*"
           destdir="build/docs"
           sourcepath="src"
           docletpath="${jar.file}"
           bootclasspath="${javahome}/jre/lib/rt.jar"
           >
      <doclet name="com.google.doclava.Doclava">
        <param name="-stubs" value="build/stubs" />
        <param name="-hdf"/> <param name="project.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="http://download.oracle.com/javase/6/docs/api/index.html?"/>
        <param name="-federationxml"/><param name="JDK"/>
        <param name="http://doclava.googlecode.com/svn/static/api/openjdk-6.xml"/>
      </doclet>
    </javadoc>
  </target>
</project>

Using Doclava with Maven

<project>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.7</version>
        <configuration>
          <docletArtifact>
            <groupId>com.google.doclava</groupId>
            <artifactId>doclava</artifactId>
            <version>1.0.3</version>
          </docletArtifact>
          <doclet>com.google.doclava.Doclava</doclet>
          <!--
            | bootclasspath required by Sun's JVM
          -->
          <bootclasspath>${sun.boot.class.path}</bootclasspath>
          <additionalparam>
             -quiet
             -federate JDK http://download.oracle.com/javase/6/docs/api/index.html?
             -federationxml JDK http://doclava.googlecode.com/svn/static/api/openjdk-6.xml
             -hdf project.name "${project.name}"
             -d ${project.build.directory}/apidocs
           </additionalparam>
          <useStandardDocletOptions>false</useStandardDocletOptions>
          <!--
            | Apple's JVM sometimes requires more memory
          -->
          <additionalJOption>-J-Xmx1024m</additionalJOption>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

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.

Customization

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:

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

and many more ....

Leave a Reply

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

*


− six = 3

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close