Search code examples
javaintellij-ideajavadoc

In IDEA, how to generate javadoc for new type?


In Eclipse, alt + shift + J on a new type, will generate javadoc with author & date.

e.g

/**
 * @author eric
 * @date Apr 3, 2015 8:49:31 PM
 */

In IDEA, I tried, but it just generate an empty Javadoc without author or date.

e.g

/**
 * 
 */

The question is:

  • In IDEA, how to generate a javadoc same as Eclipse does, with the author & date part?
  • Is it possible to generate it automatically on type creation?
  • What is the default shortcut for that?

@Update - summary

According to comment and answer, following javadoc is added to file template:

/**
 * @author ${USER}
 * @date ${DATE} ${TIME}
 */

for file type: Class, Interface, Enum, AnnotationType.

The javadoc will be added on type creation automatically.
But still seems there is no shortcut to add it by hand for existing types.


Solution

  • For classes, interfaces, etc., you can edit File Template: Preferences | Editor | File and Code Templates.

    /**
     * @author Eric
     * @date ${DATE}
     */
    

    For methods, that can be generated (like getters, setters) you can use this answer: https://stackoverflow.com/a/38094408/3124227

    For methods there is no functionality to edit javadoc: https://youtrack.jetbrains.com/issue/IDEA-97658