My favorites | Sign in
Project Logo
                
Feeds:
People details
Project owners:
  laurentszyster

Doctest for Java

This port of Python's Doctest provides a simple implementation of javadoc's Doclet interface that produces XML fragments, a JSON index and javascript tests.

CSS, HTML and an AJAX documentation browser are also included.

This package is a work in progress, I use it to document less4j.

Document and test Java at once

Text tagged with @test is compiled by Rhino and saved individually in a doc/tests folder. Tests are expected to be a simple script that returns a boolean, true for success and false for failure.

Here is what a brief Doctest comment would look like for java's String.equals method:

/**
 * Compare this <code>String</code> to another one.
 * 
 * @param string to compare to 
 * @return <code>true</code> if the two strings compared are equals
 *
 * @test return (
 *    "A".equals("A") == true &&
 *    "A".equals("a") == false
 *    );
 */

For documentation purposes doctestj supports the original javadoc tags: @param, @return and @throws. And to enhance your documentation with HTML elements with less markup error, it maps a @h3, @h4, @p and @pre tag to the equivalent HTML titles, paragraph and preformatted text elements. Any other tag (including test) will yield a div element with a CSS class named after the tag. You can still use XHTML markup inside the tagged and the untagged comment text, doctestj will try to validate it and document any XML errors in its output.









Hosted by Google Code