72

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.

nbro
  • 15,395
  • 32
  • 113
  • 196
KarolDepka
  • 8,318
  • 10
  • 45
  • 58

9 Answers9

120

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

Manu Sharma
  • 656
  • 1
  • 7
  • 22
chance
  • 6,307
  • 13
  • 46
  • 70
  • 3
    Note: Same for IntelliJ 15 – Andrejs Jul 15 '16 at 07:46
  • 3
    New: "Fix doc comment" action to fix Javadoc in case it is already there. – Roland Apr 18 '17 at 09:31
  • This should be the accepted answer instead of the one from 2009, technologies evolve. – Gherbi Hicham Sep 17 '19 at 09:12
  • 1
    Roland's comment is the closest thing to what Eclipse offers, as far as generating a text block is concerned. Put the cursor on the code to generate the javadoc for, then `Help > Find Action...` then start typing "Fix doc comment". Once it's selected, press Enter to execute the action and generate the text. You can also go into the keybindings menu, search for the same action, and assign a keybinding to it. (I *think* the text inserted is based on the Live Templates, but I don't do this often enough to tell or care.) – Ti Strga Apr 21 '20 at 13:58
36

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.

aelkz
  • 1,786
  • 1
  • 24
  • 26
  • 2
    Of course, it is **very annoying** to manually invoke the _create Javadoc stubs _ command for each property, method, ... – Tom Jul 23 '19 at 19:46
11

It's not possible at the moment. You may want to Vote for IDEABKL-1787.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • 2
    Thanks. That's a weird ommision by JetBrains. I will vote on friday. But the ticket does not concern _automatically_ adding javadoc for generated stuff. Maybe there is a plugin for this and that? – KarolDepka Dec 03 '09 at 23:07
  • 7
    IDEA doesn't generate JavaDoc stubs automatically, only when you type /** and press Enter. There is an old IDEA doc plug-in not compatible with the recent IDEA versions: http://plugins.intellij.net/plugin/?id=952 . Maybe someone will rewrite it. – CrazyCoder Dec 03 '09 at 23:48
8

for generate javadoc in intellij Idea go to Tools->Generate JavaDoc (4th option) click it and give path to save your Document

Rinkesh
  • 3,150
  • 28
  • 32
4

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

Damian
  • 81
  • 3
3

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.

Evvo
  • 481
  • 5
  • 8
2

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.

  • I have installed this plugin but could not find a way to generate comments for all methods in a class. Could you please tell me how to do it? – ashisahu Sep 22 '16 at 20:01
  • Version #10 of Plugin exists now. The helps says to turn on the JavaDoc Sync plugin, go to Settings->Errors and select "JavaDoc issues". But there is no Errors under settings :-( Uninstalled and used @chance solution – boardtc Apr 09 '20 at 15:01
  • the #10 ver seems to be at https://plugins.jetbrains.com/plugin/6340-javadoc-sync-plugin-10 – George Birbilis Jun 07 '21 at 06:28
1

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.

0

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

RobC
  • 22,977
  • 20
  • 73
  • 80
Ivo Varbanov
  • 59
  • 1
  • 3