Saturday, March 24, 2012

Eclipse: Writing Better, Faster Java Documentation

JAutodoc:
I've started using JAutodoc, which is an Eclipse plugin for automatically adding Javadoc to your source code. It helps generate the initial Javadoc for methods which don't have them and can even complete existing Javadoc by adding missing parameters and return types. I have found this plugin very useful in writing documentation fast.

Let's say you have the following method which adds two ints:

public int add(int x, int y) {
    return x + y;
}
To invoke JAutodoc, all you have to do is hit Ctrl+Alt+J inside the method and the following Javadoc template will be automatically generated, which you can then complete.
/**
 * Adds the.
 *
 * @param x the x
 * @param y the y
 * @return the int
 */
public int add(int x, int y) {
    return x + y;
}
Later on, if you decide to change this method by adding another parameter to it, you can press Ctrl+Alt+J again and JAutoDoc will add the new parameter to the Javadoc but leave the rest of it unchanged.

Enabling Eclipse Javadoc warnings:
I've also found it useful to turn on Eclipse warnings for missing or malformed Javadoc comments. You can do this by going to Window > Preferences and then selecting Java > Compiler > Javadoc. Tick the box for processing Javadoc comments and select your desired severity levels. I've got mine set to Warnings for everything. You can get my Eclipse preferences from my git repository.

4 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. NIce....exellent Job...Thank you so much for this post! I’m self taught and have never really been able to meet other UI designers, but now I’ll be able to go to my very first design conference and be completely humbled!
    にほんNCH 

    ReplyDelete
  3. Hello. I have been visiting various blogs for my research work. I have found your blog to be quite useful. Keep updating your blog with valuable information.....!!

    las vegas injury lawyers

    ReplyDelete
  4. Thanks very helpful for me personally, because it consists of large amount of information. I usually would rather read the standard content

    floor cleaning products

    ReplyDelete