views:

1702

answers:

5

Is there a way to generate javadoc comments in eclipse?

A: 

JAutoDoc

antony.trupe
after finding the answer on google, I researched SO and found this answer: http://stackoverflow.com/questions/29689/javadoc-template-generator/31946#31946
antony.trupe
I actually am going to try to avoid using this plugin, but will leave the answer(unless it gets down-voted) to close any information circles.
antony.trupe
+1  A: 
  1. At a place where you want javadoc, type in /**<NEWLINE> and it will create the template.
  2. Under the Project menu: Generate Javadoc.
bmargulies
1. that works, thank. 2. that menu item isn't in any of the perspectives I use.
antony.trupe
im interested to know what your perspective is
medopal
A: 

You mean menu Project -> Generate Javadoc ?

Luno
That menu item isn't in any of the perspectives I use.
antony.trupe
It's on my Eclipse, and the only extra things I've installed are Google Web Toolkit and FindBugs. (This is Ganymede, not Europa. Maybe you need to upgrade?)
Paul Tomblin
I only have the gwt perspective, eclipse v 3.5.1
antony.trupe
Maybe you need to install Eclipse for Java Developers or Eclipse for J2EE developers.
Jherico
What happens if you go to Preferences->Java->Code Templates and click "restore defaults"? Because I have code templates for comments that includes all the javadoc stuff.
Paul Tomblin
it appears all the templates are present. I clicked "restore defaults" to be sure nothing crazy is going on. I just don't have that menu option. My hunch is I have a subset of the "usual" features of eclipse.
antony.trupe
Anyway, this is not what the OP is looking for. The question (which is a bit misleading) is not about generating the javadoc but adding javadoc "comments" in the code.
Pascal Thivent
+2  A: 

Shift-Alt-J is a useful keyboard shortcut in Eclipse for creating Javadoc comment templates.

Invoking the shortcut on a class, method or field declaration will create a Javadoc template:

public int doAction(int i) {
    return i;
}

Pressing Shift-Alt-J on the method declaration gives:

/**
 * @param i
 * @return
 */
public int doAction(int i) {
    return i;
}
coobird
+4  A: 

For me the "/**<NEWLINE>" or "Shift-Alt-J" approach works best.

I dislike seeing Javadoc in source code that has been auto-generated and then had no effort put into adding any real content added. As far as I am concerned they are nothing more than a waste of screen space.

IMO, it is much much better to generate the Javadoc comment skeletons one by one as you are about to fill in the details.

Stephen C
To save space, fold it!
Pascal Thivent
@Pascal - I'd prefer to delete it/them, or not generate it/them in the first place. IMO, generated javadoc comments add zero value ... unless you count a bogus boost to the comment-to-code ratio as "value".
Stephen C