Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Measuring Documentation Coverage with Javadoc and Ant

Tags:

I am involved in a project in which public API documentation is a clear deliverable. In order to ensure that the release meets this requirement, I'd like to ensure that the the release target in my Ant build file fails if documentation coverage is too low.

As a minimum, each identifier with public or protected access should have appropriate Javadoc tags and a description. For example, public methods should have a @param tag for each parameter, a @return tag if the return type is not void, a @throws tag for each exception, and a single line description.

I currently have JUnit code coverage reports and failure conditions using Cobertura, so something similar to that for documentation would be perfect. However, if the detection of a failure condition is not available, a report be a reasonable substitute.

The documentation must be in Javadoc format. No other format -- including Doxygen -- is acceptable.

like image 368
David Grant Avatar asked Feb 19 '09 13:02

David Grant


People also ask

What is Javadoc documentation?

Javadoc is a documentation tool which defines a standard format for such comments, and which can generate HTML files to view the documentation from a web broswer. (As an example, see Oracle's Javadoc documentation for the Java libraries at http://download.oracle.com/javase/6/docs/api/.)

What is the purpose of the Javadoc tool?

Javadoc is a tool for generating API documentation in HTML format from doc comments in source code. It can be downloaded only as part of the Java 2 SDK. To see documentation generated by the Javadoc tool, go to J2SE 1.5. 0 API Documentation.

Which Javadoc tag is used to document exceptions thrown by a method?

A @throws tag should be included for any checked exceptions (declared in the throws clause), as illustrated below, and also for any unchecked exceptions that the caller might reasonably want to catch, with the exception of NullPointerException . Errors should not be documented as they are unpredictable.

How can you generate Javadoc documentation for your code?

Step 1 − Open eclipse, select the option Project →Generate Javadoc. Step 2 − Select the javadoc.exe file from the bin folder of java installation directory, select the destination folder for the generated java doc and select Next. finish button.


1 Answers

Checkstyle can do that.

like image 142
starblue Avatar answered Sep 24 '22 05:09

starblue