Is it possible to auto-generate Javadoc comments for each method in one class in Eclipse (Indigo)?
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.
The other choice might be to double click on the name of the method, then ALT+Shift+J shortcut.
There also exist external tools for javadoc generation, for example JAutodoc eclipse plugin. It is possible to customize it's templates to suit your expectation.
In Eclipse you have possiblity to create java doc template, and then just what need to do is type java-dock block /** above the element you want to document.
In case when the code is generate, the templates also generate the java-doc.
All this and even more you will be able to configure in Window -> Preferences, Java -> Code Style -> Code Templates -> Comments
Related
I know PMD can be exectued on command line and an output file specified there, but for certain reasons simply saving the Eclipse plugin results to a file would make life easier.
Is there any way to do this? I've hunted around for this but haven't found a solution.
This functionality is a bit hidden, but it exists.
Go to "Window -> Preferences -> PMD -> Reports" and select the report format, you want, e.g. "text".
Right-click on the project and select "PMD -> Check Code".
Right-click on the project and select "PMD -> Generate Reports".
Now, you should have a new folder reports in your project, which contains a file pmd-report.txt.
It seems, that a report is only created, if there are violations, hence the 2nd step (e.g. there must be at least one violation marked in the project).
Edit: This assumes, you are using the pmd-eclipse plugin from this update site: https://sourceforge.net/projects/pmd/files/pmd-eclipse/update-site/ - note, there is also an alternative eclipse-pmd plugin available.
When writing Javadoc for a class and when I wish to add a link to another class, I type:
{#link SomeCl<TAB>}
and IDEA completes with the full import, ie it will yield {#link com.foo.SomeClass}; only afterwards can I choose to "replace with import".
Is there a way to tell IDEA to use imports in this situation instead?
(this is all the more frustrating that it does so automatically for code... Just not Javadoc)
Problem solved. I should explore the configuration options further!
File -> Settings -> Code Style -> Java, select tab "imports", there is an option to Use fully qualified classnames in Javadoc which was checked. Simply uncheck it...
I'm using Eclipse Indigo for Java.
I used to write comments over the methods.
In that whenever I use #author tag, it automatically takes the username of the system who is currently logged in.
My question is : How can I change this #author tag configuration in such a way that it takes the name I have specified.
I have gone through the following link:
How to change the value of ${user} variable used in Eclipse templates
But it suggests to change the value of classpath variable $user.
I don't want to do that. I want to change comment template through configuration.
There are several ways of accomplishing this. Open up Eclipse Preferences, type in Templates as your Filter, then select Java->Code Style->Code Templates. In the Code Templates widget, expand the Comments widget:
Looking through the expanded selection, you can see that there are templates defined for Types and Methods, amongst others. Select whichever template you want to edit, then click 'Edit'. You can now change the template as you see fit, for example by adding #author ${user} or whatever else to it:
Click 'Ok' out of all the dialogs to complete and save.
In the eclipse directory there is a file named: "eclipse.ini" open the file and add following line:
-Duser.name=desired name
after the "-vmargs" line
Project->Properties->Java Code Style->Code Template->
There is link Configure workspace setting
Select Comment->Types
Edit your name or whatever you want.
You can go to the Windows/Preference. Type int "Template" in the search box and go to Java/Code Style/Code Templates. The area you are searching is in the "Comments" part.
I dislike the default Javadocs generated for me when I create a Class or methods, especially the #author variable, which is the current system username on my windows box.
I would like to change it. Is this possible?
Check Preferences / Java / Code Style / Code Template
Section Comment / Type
You can replace the author tag by whatever value you need and it will have an effect on new generated classes.
However, if the template is fine, but the value referenced buy the author tag is not, see this SO question:
${user} uses the value of the user.name environment variable; therefore, you can pass -Duser.name=My Name in eclipse.ini to override it.
Or, if you prefer, you can modify the shortcut to point to:
C:/java/eclipse/eclipse.exe -vmargs -Duser.name="cleverUserNameToUseInSourceCode"
MacOs: Aram Kocharyan mentions the eclipse.ini is in Eclipse.app/Contents/MacOS/ if you right click and go Show Package Content.
ZendStudio: rofflox comments the file is named ZendStudio.ini and is found in Applications/Zend Studio.app/Contents/MacOS/.
Look at Window -> Preferences -> Java -> Editor -> Templates.
Spring Tool Suite (popular Eclipse customization for Spring development) uses STS.ini. On Windows I found it in the same dir as an app launch executable.
To use a Git username and email you can use the variables ${name:git_config(user.name)} and
${email:git_config(user.email)}.
You should consider using JAutodoc, which is a very useful plugin for Eclipse. The parametrization is way more advanced than the standard Eclipse generation.
Is it possible to set up Intellij to generate javadoc for methods and classes, automatically, with #author and #since date? I had this feature in Eclipse.
I know that the files have templates and also I can manually semi-automatically add javadoc to selected method/class. But I want the generation to be automatic for every generated method/class/enum/interface/field etc.
This is useful for e.g. "extract method", "override/implement", "create getter/setter" etc. This would save hundreds of manual actions.
I'm using IntelliJ Idea 9.0 BETA Community Edition, #IC-90.96.
For IntelliJ 12:
Position caret above a method name, type /** and press Enter to let
IntelliJ IDEA automatically generate JavaDoc stubs for this method.
See here
For newer versions of IntelliJ (2018+), you can use this solution:
Typing /** + then pressing Enter above a method signature will create Javadoc stubs for you.
It's not possible at the moment. You may want to Vote for IDEABKL-1787.
for generate javadoc in intellij Idea go to Tools->Generate JavaDoc (4th option) click it and give path to save your Document
Now there is a new plugin available for that.
It works great, you can generate javadoc with alt+insert.
It's called "javaDoc", it's available directly in the plugin section.
The documentation is here : https://github.com/setial/intellij-javadocs/wiki
I have given up on hoping that IntelliJ will be able to do this.
I now open my project in Eclipse, go to the desired files and invoke JAutoDoc.
There is JavaDoc Sync Plugin 8. http://plugins.intellij.net/plugin/?idea&id=3403
Generates javadoc for all methods in class. Works in Idea 10.
Actually it's now possible, you can simply go to "Settings/Editor/File and Code Templates".
There, you can edit the template which is used to create classes, enums, interfaces etc.
My Intellij version is 2019.2.3 and on linux.
An easy option is to access Find Action menu (Macs: Cmd+Shift+A | Win: Ctrl+Shift+A) and type any part of the Generate JavaDoc action.
Once you found and clicked on that , an option menu for generation of JavaDocs is opened , containing a wide range of options and scopes.
Reference -> https://www.jetbrains.com/help/idea/mastering-keyboard-shortcuts.html