Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autogenerate function comments in Eclipse

Tags:

java

eclipse

How to autogenerate xml based function header comments (@param etc) in Eclipse. Is there an equivalent of "///" shortcut in Visual Studio.

like image 709
softwarematter Avatar asked Oct 27 '10 12:10

softwarematter


People also ask

How do I Autogenerate comments in Eclipse?

There may be a better approach, but if you expand the class in Package Explorer, select the methods you would to document, then right-click and select "Source -> Generate Element Comment" that will add comments for all the selected methods.

How do I create a function comment in Eclipse?

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

How do I get commented code from Eclipse?

Finding comments is easy: search for "/*" or "//". And since comments have no formal relation to code, when is a comment "about" the code nearby, and when is it just a comment ("a sonnet to ...")?


4 Answers

In the line just before the method definition, type /** and hit enter.

In the IDE, type /** just before the method and hit enter. Eclipse will autogenerate the Javadoc tags and the end */

type /** here and his enter, eclipse will generate the javadoc tags and the end */
public void setName(String name)
{
   ...
}
like image 64
Nivas Avatar answered Sep 29 '22 19:09

Nivas


You can do this by clicking ALT+Shift+J inside the method/class. | It's not XML Based though, but you can generate JavaDoc by clicking Project->Generate JavaDoc... in the menubar.

like image 31
Faizan S. Avatar answered Sep 29 '22 18:09

Faizan S.


You can specify what is autogenerated in Eclipse by going to Window->Preferences

Under, Java -> Code Style -> Code Templates; is the list of what comments get put where. You can google for the syntax of how to insert the different param names and other constants so that you can generate whatever comment you wish, be it Javadoc or other.

As Nivas said, typing /** then hitting enter will auto insert a the comment.

like image 39
Andrew Avatar answered Sep 29 '22 19:09

Andrew


http://jautodoc.sourceforge.net/

JAutodoc is an Eclipse Plugin for automatically adding Javadoc and file headers to your source code. It optionally generates initial comments from element name by using Velocity templates for Javadoc and file headers.

like image 22
gulbrandr Avatar answered Sep 29 '22 18:09

gulbrandr