Reduce Java Code commenting effort using JAutodoc (eclipse plugin)

JAutodoc is a very useful eclipse plugin which helps in generating javadoc style comments very easily.

Reduce Java Code commenting effort using JAutodoc (eclipse plugin)

Reduce Java Code commenting effort using JAutodoc (eclipse plugin)

     

INTRODUCTION

Summary

JAutodoc is a very useful eclipse plugin which helps in generating javadoc style comments very easily. Apart from adding the template for javadoc style comments for the class/method & attributes it is smart enough to add the description also based on the signatures. This can cover a substantial part of description creation effort for the methods like the setters/getters etc which do not need much human skills to generate the descriptions.

Installation


Unzip the jautodoc_1.5.0.zip file from the eclipse folder.
Verify the following files get copied as shown :
Plugin folder :



Features folder



Restart eclipse.
The JAutodoc feature should be available in preferences



Usage


Select the whole file or method or attribute -> Rightclick -> Add Javadoc



Advantages over eclipse provided Javadoc generation

  • Commenting the whole file in one click is possible, eclipse provides only on element basis
  • File heading is possible
  • Preserves the previous Javadoc comment, where as eclipse blindly adds another comment on the same element if run again.
  • Can define various parameters like $author etc. Where as eclipse has fixed number of parameters and their value is not definable.
  • Can generate descriptions for variables/methods based on some logic, eclipse can generate descriptions for only set / get type methods.

Recommended Settings

General Settings





File Header

What ever is set here, will appear in the top of each Java file.
Sample:
*
* ****************************************************
* * Product Catalog *
* * Release 1 . 00 *
* * ABC Technologis Ltd. *
* ****************************************************
*/

Templates



Define properties








Refer the property as $author in the templates.

Method returning values

/**
* ${e.g(2).rsfu()} .
* @param
* @return ${e.g(1).rsfl()}
* @throws
* @author $author

*/

Eclipse setting for overridden methods





Set it like, as the default eclipse setting generates non javadoc comment, and does not have provision to add project specific description if required.

/**
*
* ${see_to_overridden}
*/

Export Templates


Export templates after preparing on one machine & testing, to the whole team :


Import templates


Importing of the project template by every developer in the team



Example

Before

package VSpring2.service;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class PriceIncrease
{
/** Logger for this class and subclasses */
protected final Log logger = LogFactory.getLog(getClass());
private int percentage;
public void setPercentage(int i) {
percentage = i;
logger.info("Percentage set to " + i);
} public int getPercentage() {
return percentage;
}
}

After JAutodoc


/*
* ****************************************************
* * SPRING REFERENCE APPLICATION *
* * Release 1.00 *
* * Technology Solution Group - MFG BU *
* ****************************************************
*/
package VSpring2.service;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* The Class PriceIncrease.
*/
public class PriceIncrease
{
/** Logger for this class and subclasses */
protected final Log logger = LogFactory.getLog(getClass());
/** The percentage. */
private int percentage;
/**
* Sets the percentage.
*
* @param i the new percentage
*/
public void setPercentage(int i) {
percentage = i;
logger.info("Percentage set to " + i);
}
/**
* Gets the percentage.
*
* @return the percentage
*/
public int getPercentage() {
return percentage;
}
}