May 14, 2015

Eclipse and Javadoc with PDF Generation

Javadoc is a tool for Java source code documentation generation. Just write in the source code using Javadoc annotations and then it build HTML files, containing the source code classes, methods, parameters, returns and so on. But how generate in a single PDF file?

Plugin is the answer! Javadoc supports plugins, one of the them is the "AurigaDoclet" that provides PDF file format. A simple example can be seen below:

       /**  
       * Set the Circle fill color, accepts HTML color codes  
       * @param fillColor Ex: "blue" or "#FF0000"  
       */  
      public Circle setFillColor(String fillColor) {  
           this.fillColor = fillColor;  
           return this;  
      }  
This example starts with the Javadoc annotation /** then a description about the method and finally the @param to describe the String fillColor parameter of the setFillColor method. Now go to Project -> Generate Javadoc:

Select Use custom doclet and place "com.aurigalogic.doclet.core.Doclet" in the Doclet name, in the Doclet class path point to the AurigaDoclet.jar file in the bin folder where you extracted the plugin files:


Don't forget to select the files for Javadoc generation! Now click Next and specify the format (-format pdf) and output dir (-out d:\javadoc.pdf) where the file will be generated:


Click Finish and you should see on Console something like this:


Now open the PDF file and enjoy! The result for this example is the following:



That's all!

About the versions
  • Eclipse Java EE IDE for Web Developers Luna Service Release 1 (4.4.1)
  • jdk1.8.0_31
  • AurigaDoclet-0.1b

0 comentários :

Post a Comment