1

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.

Eric
  • 22,183
  • 20
  • 145
  • 196
  • 3
    You should customize file templates : https://www.jetbrains.com/help/idea/using-file-and-code-templates.html – Amir M Dec 29 '18 at 08:41

2 Answers2

2

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

Feedforward
  • 4,521
  • 4
  • 22
  • 34
  • Ok, I have solved it. BTW, there are more placeholders `${USER}` for system user name, `${DATE} {TIME}` to get both date & time, and I apply this to `Class`, `Interface`, `Enum`, `AnnotationType`, now it works very similar as in Eclipse. – Eric Dec 29 '18 at 09:16
-2

Why do you want to? This is precisely the kind of information that a version control system helps you track! For example, you can get this from Git by running git log --diff-filter=A --follow path/to/my/Class.java.

(Thanks to https://stackoverflow.com/a/13598028 for the specific snippet.)

To be clear, I'm not against Javadoc as a whole, only using it to manually track information that is automatically tracked elsewhere.

Teo Klestrup Röijezon
  • 5,097
  • 3
  • 29
  • 37
  • The issue in the question intends to help while viewing source code, not actually relevant to any version control system, that's another story. – Eric Dec 29 '18 at 09:12
  • And, when you publish the code as jar, the user don't necessary have access to scm like Git, that's when javadoc is even more important to get information like this. – Eric Dec 29 '18 at 09:21
  • @EricWang If you can give them a source code dump then you can give them SCM access. That said, this is not particularly useful as an external user anyway. In that case I care about things like the version number where it was added, not which date. – Teo Klestrup Röijezon Dec 29 '18 at 09:29