Search

Dark theme | Light theme

May 26, 2009

Automatically generate Javadoc skeleton code in NetBeans

NetBeans can help us with generating a starting point for Javadoc documentation. Suppose we have the following simple Java class:

package javaapplication16;

public class Main {

    public static void main(String[] args) {
        final Main app = new Main();
        app.sayHello("mrhaki");
    }

    public void sayHello(final String name) {
        System.out.println("Hello " + name);
    }

}

We right-click on the Sources Packages and select Tools | Analyze Javadoc.

NetBeans generates a list of all sources files with missing javadoc in the Analyzer window:

We select the files and methods and then hit the Fix Selected button to let NetBeans generate skeleton javadoc code:

package javaapplication16;

/**
 * 
 * @author mrhaki
 */
public class Main {

    /**
     * 
     * @param args
     */
    public static void main(String[] args) {
        final Main app = new Main();
        app.sayHello("mrhaki");
    }

    /**
     * 
     * @param name
     */
    public void sayHello(final String name) {
        System.out.println("Hello " + name);
    }

}

Now all we have to do is provide meaningful documentation.