“Fix Doc Comment” Action is Available

A new action for code documentation maniacs, called Fix doc comment, has just been cooked at the JetBrains’ oven.

Please follow the recipe:

  • Find or create a stub doc comment.
  • Fix documentation problems quickly whenever you wish.

The first case, when you may need the new action, is rather simple. Call it, when a caret is somewhere within a class, field or method, which does not have a doc comment. A doc comment stub will be added, and the caret will be moved to proper position for entering a comment.

The second use-case for the new action, is to fix an existing documentation problems. For example, the signature of some method has been changed, and the doc comment is valid anymore. We have an inspection, which allows to fix such problems one-by-one. It adds missing @param tag, return outdated @return, etc. The new action can fix these problems at once.

Note, that by default there is no any shortcut assigned to this action. However you can do it by yourself in Settings | Keymap.

We hope the new action will save your time, when you document your code or just fix the problems.

Currently the new action is available only for Java. But we hope to implement it soon for other languages too.

Please find this feature in the latest IntelliJ IDEA 12 EAP and submit your feedback to our issue tracker.

Comments below can no longer be edited.

18 Responses to “Fix Doc Comment” Action is Available

  1. Avatar

    Arikon says:

    September 26, 2012

    This feature do not work with JavaScript code =(

  2. Avatar

    Denis.Zhdanov says:

    September 26, 2012

    The feature works with java code only at the moment. However, it’s implemented in pluggable manner, that’s why it wouldn’t be hard to provide it for other languages. Please submit corresponding feature request that targets js support.

  3. Avatar

    jtonic says:

    September 27, 2012

    It would be great if the action have a default shortcut (Alt+Shift+J – Eclipse shortcut for creating a javadoc comment).

    Useful feature

    Thank you

  4. Avatar

    Denis.Zhdanov says:

    September 28, 2012

    Sorry but that shortcut is already occupied by ‘Surround with Live Template’ action. It has been at the IDE for a while and many users are accustomed to it.


  5. Avatar

    Philip Herbst says:

    September 28, 2012

    What about Ctrl+Alt+Shift+J?


  6. Avatar

    Erik Pragt says:

    September 28, 2012

    Hmm, for me, it doesn’t work. I’ve created a method, say:
    * @param object The object to process
    boolean isProcessed(WorkItem item)

    ‘object’ here is of course an incorrect parameter name, so I ‘fix’ it using my shortcut (ctrl+shift+alt+p), and nothing happens. If I remove the documentation, the document template is added, but fixing doesn’t work.

  7. Avatar

    Erik Pragt says:

    September 28, 2012

    I just checked it a bit more, and when there is already Javadoc on the method, my shortcut doesn’t jump to the Javadoc, either if it’s correct or incorrect. But maybe I’m missing the idea of this shortcut?

  8. Avatar

    Denis.Zhdanov says:

    September 28, 2012

    You got the idea right, it looks like the ‘fix’ part hasn’t been included to the last EAP. Please wait for the next build.

  9. Avatar

    Erik Pragt says:

    October 3, 2012

    Okay, thanks Denis, will do!

  10. Avatar

    Björn Kautler says:

    August 10, 2013

    You are missing a “not” in “For example, the signature of some method has been changed, and the doc comment is valid anymore.” 🙂

  11. Avatar

    Dennis says:

    August 3, 2015

    Fix Doc Comment appears to be working in JavaScript!!!!

    Please fix documentation

    • Avatar

      Dennis says:

      August 3, 2015

      In Javascript, Fix Doc Comment only works in limited circumstances. For instance, it works when you have a cursor within the parameter list, setting the jsDoc parameters correctly. If you are within an if or for (or perhaps switch, …) block, it will document that block. If you are any other place withing the function block, it does not work.

  12. Avatar

    Serge says:

    September 14, 2017

    Can I modify doc comment template to have one-line comment by default?

    Like /** Doc contents */

    • Avatar

      duyj says:

      July 17, 2018

      I want find this function too

  13. Avatar

    Andrew says:

    February 8, 2018

    How to make it done in Kotlin ?

  14. Avatar

    Mathieu says:

    March 22, 2018

    Is there a way to run to run this action on the whole project scope? I would like to avoid having to do this action for every javadoc that might be out of sync with the code in my project.

  15. Avatar

    Nam Nguyen says:

    May 17, 2018

    Does this work for PHP yet?

  16. Avatar

    Jones says:

    January 3, 2019

    We need to use it on kotlin

Discover more