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:

Related Whitepaper:

Bulletproof Java Code: A Practical Strategy for Developing Functional, Reliable, and Secure Java Code

Use Java? If you do, you know that Java software can be used to drive application logic of Web services or Web applications. Perhaps you use it for desktop applications? Or, embedded devices? Whatever your use of Java code, functional errors are the enemy!

To combat this enemy, your team might already perform functional testing. Even so, you're taking significant risks if you have not yet implemented a comprehensive team-wide quality management strategy. Such a strategy alleviates reliability, security, and performance problems to ensure that your code is free of functionality errors.Read this article to learn about this simple four-step strategy that is proven to make Java code more reliable, more secure, and easier to maintain.

Get it Now!  

Leave a Reply


six + = 13



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.

Sign up for our Newsletter

15,153 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books