Blog




In recent posts we showed how to configure taglets within you Maven build to create visually appealing API documentation with Javadoc. In Using Taglets with Java 7 we showed how to tweak your configuration to get them running with Java 7.

Here we are giving some code samples to get you started using it. In the following five sections we show first the rendered example and then the code that produced it as part of the Javadoc comment. You may download a zipped Java file containing all examples shown below to quickly check your installation.

 

Please note that in the examples the end pre tag is ‘damaged’ since I had difficulties to render the examples. Adding the pre element to surround the code helps the Eclipse formatter to keep these sections untouched.

Note

 * <pre>
 * {@stickyNote "Note"
 * This is a <i>note</i>.
 * }
 * 

XML Markup

 * <pre>
 * {@markupExample "POM Dependency"
 * &lt;dependency&gt;
 *  &lt;groupId&gt;xerces&lt;/groupId&gt;
 *  &lt;artifactId&gt;xercesImpl&lt;/artifactId&gt;
 *  &lt;version&gt;2.10.0&lt;/version&gt;
 * &lt;/dependency&gt;
 * }
 * 

Java Code

 * <pre>
 * {@source
 *     final OutputStream out = ...;
 *     try {
 *       final PropertiesPropertyReport report = new PropertiesPropertyReport(out);
 *       final ReportBuilder reportBuilder = ReportBuilder.create(configuration);
 *       reportBuilder.reportTo(report);
 *       myHelper.reportProblems(report);
 *       report.flush();
 *     }
 *     finally {
 *       IOUtils.closeQuietly(out);
 *     }
 *   }
 * 

Java Code with Annotations

 * <pre>
 * {@source "Usage Example"
 * {@annotation}DocTag("parent-tag")
 *   public interface TestProperties
 *   {
 *     String inheritAll();
 *
 *     {@annotation}DocTag({ "sample-tag one" })
 *     String oneValue();
 *
 *     {@annotation}DocTag({ "sample-tag one", "sample-tag two", "sample-tag three" })
 *     String multipleValues();
 *   }
 * }

Tables

 * <pre>
 * {@table [noheader] [nofill]
 *   || header 1 | header 2 | ... | header N ||
 *   || cell 1/1 | cell 1/2 | ... | cell 1/N ||
 *   || cell 2/1 | cell 2/2 | ... | cell 2/N ||
 *   ...
 *   || cell M/1 | cell M/2 | ... | cell M/N ||
 * }
 * 

Other Tags

Have look at more examples of predefined tags on the taglets homepage!


Link

Link

Posts