Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How configure Intellij Idea javadoc templates?

Tags:

I have some method:

public int getSomeField() 

I want to generate javadoc like this:

/** * Gets {someField} * * @return value of {someField} */ 

Where {someField} is placeholder for field name. It is possible to create this templates for Intellij Idea (may be as live template)?

like image 306
Cherry Avatar asked Jul 12 '13 05:07

Cherry


People also ask

How do I use Javadoc in IntelliJ?

From the main menu, select Tools | Generate JavaDoc. In the dialog that opens, select a scope — a set of files or directories for which you want to generate the reference, and set the output directory where the generated documentation will be placed.

Where are IntelliJ templates stored?

IntelliJ IDEA stores global templates in the IDE configuration directory under fileTemplates. Project: configure file templates specific for the current project. These templates are available to everyone who works on this project. IntelliJ IDEA stores them in the project folder under .

How do I create an automatic Javadoc?

In the Package Explorer view, select a Java project and click Project > Generate Javadoc with Diagrams > Automatically. In the Generate Javadoc wizard, under Javadoc command, select the Javadoc command (an executable file). Note: Only Oracle JDK Version 1.4.


2 Answers

Bring up the Generate menu (Cmd+N on Mac, Alt+Insert on Windows)

Generate menu

Click the ellipsis in the top right hand corner.

Generate Getters menu

Click the plus in the top left corner and create a new template. Create new template dialog

Copy the contents of the old template into the new template and add the following lines to the top of it.

/** * Gets $field.name * * @return value of $field.name */ 

enter image description here

Now when you generate the getter use the 'New Template' and you should get your getter with the JavaDoc.

Select New Template

enter image description here

like image 82
Will Humphreys Avatar answered Sep 16 '22 21:09

Will Humphreys


You generate Javadoc by placing the caret above the method. Then you type /** and press Enter.

Unfortunately the template can't be changed and there is a request for that: http://youtrack.jetbrains.net/issue/IDEA-28206

like image 39
maba Avatar answered Sep 17 '22 21:09

maba