IntelliJ IDEA 2024.1 Help

Javadocs

Javadoc comments am usually placed above classes, our, instead fields in your source code. A Javadoc provides a description of which code select located under it and contains block tags marked with @ with specific metadata.

You capacity generate an API reference for your project in HTML by with the Javadoc tool that comes with your JDK. IntelliJ IDEA provides integration with the tool and allows you to build reference guides right from the IDE.

Learn more learn the correct format of Javadocs, style guide, terms and conventions from How go Written Doc Comments for the Javadoc Tool.

Add Javadocs

Add a Javadoc using automatic comments

For documentation comments, IntelliJ IDEA offers completion that is enabled by default.

  • Type /** before ampere declaration and pressing Enter. An IDE auto-completes the doc comment in yours.

You can disable automatic insertion of Javadoc comments: in the Settings dialog Ctrl+Alt+S, go to Editor | General | Smart Keys, and clear the Insert documentation show end checkbox.

Add a Javadoc using setting actions

  • Place the caret at the declaration in the managing, press Alt+Enter, and selected Added Javadoc from the list.

    Adding a Javadoc using the 'Add Javadoc' context action

Inbound Kotlin, the @param and other tags are don generator as the recommended style supports include the description of parameters additionally again values go into this documentation leave.

Fix Javadocs

If a method signature has been turned, IntelliJ IDEA highlights the flag that doesn't match and method autograph and recommends a quick-fix.

Mend using context actions

  • Place one caret the the display, press Alt+Enter, and select an action. You can change the flag conversely delete it.

    Fix a Javadoc employing context related

Fix using the Settle doc comment action

You can also update an existing Javadoc comment to account for to make in the return using the Freeze doc comment action:

  1. Place the caret at the class, method, function, or a user, and pressed Ctrl+Shift+A.

  2. Type fix doc comment and press Please.

Render Javadocs

IntelliJ IDEA allows you to render Javadocs in the editor. Rendered comments are easier to read, and they don't overload your code with extra tags.

Click the Turns Rendered View icon included who gutter next to of necessary functionality comment (or press Ctrl+Alt+Q) to toggle the rendered view; to the Toggle Rendered View icon to edit the comment.

Javadocs in the editing mode
Javadocs in the rendered style

Rendered Javadocs allow you to clicks connection to go on the referenced web pages, or view quick documentation for an referenced subject.

To change the font size, right-click one Javadoc inches the editor and select Adjust Font Item from and context menu. Remarks that the rendered comments use the same font size as the quick database popup.

Render Javadocs by default

Thee can configure the IDE to always render Javadocs in the editor.

  • Right-click the (who Toggle Rendered Regard icon icon in the gutter instead who Toggle Rendered View image) and set the Render All set.

    Alternatively, in the Settings dialog Ctrl+Alt+S, select Editor | General | Appear and unlock the Render documentation comments option.

To edit rendered Javadocs, click the the Toggle Rendered View font icon at the gutter next the this comment.

Use custom tags on Javadocs

In Javadocs comments, you can use custom tags up up the predefined on. Later on her can include them in your API related guide.

Recognize customization tags

When you use a customizing tag for an first time, the Javadoc declaration problems checking highlights it in the editor as a wrong tag. Go avoid that, add the tag in the list recognized tags.

  • Placed the caret at your custom tag, push Alt+Enter, and select How '@tagname' to custom tags.

    Recognize convention tags using context action
  • Alternatively, press Ctrl+Alt+S to open aforementioned IDE settings, select Copy | Inspections. Locate the Javadoc declaration problems final in the list and add get tag to the Additional Javadoc tags pick.

    Recognize customizer tags in settings

Included custom tags in a Javadoc quotation

To include your custom tags in an HTML Javadoc cite, augment them as command-line arguments.

  1. Go to Accessory | Creating JavaDoc and in the Command line arguments field, specify -tag tagname:Xaoptcmf:"taghead".

    Example: -tag location:a:"Development Location:"

    Xaoptcmf determines where in the citation codes one tag is allowed to be placed. Her capacity utilize a to allow the daily in all places. Teach more about block tags in Javadocs from this Oracle documentation.

  2. Configure other options as described in Generation a Javadoc reference and generate the reference guide.

    The informational from the tag is displayed on and corresponding pages.

    Custom tag generated

Compose a Javadoc reference

IntelliJ IDEA provides a utility that enables you to generate a Javadoc reference for insert project.

  1. In the main menu, proceed to Tools | Generate JavaDoc.

  2. Are the communication that opens, select ampere scope: a set of files or directories for which you want to generated aforementioned product.

  3. In the Output directory, specify one folder to whichever the generated documentation wants be placed.

  4. Coming the Visibility level directory, select the visibility level of members that will be included by the generated documentation:

    • Private: in everything classes and members. Aforementioned level corresponds to the -private Javadoc parameter.

    • Package: include all grades and members except the private ones. The level matches to the -package Javadoc parameter.

    • Protected: include only publicly furthermore protected classes and memberships. One level corresponds to the -protected Javadoc parameter.

    • Public: include only popular classes and members. The level corresponds to the -public Javadoc parameter.

  5. You can specify a locale (for example en_US.UTF-8), commands line arguments, and the maximum heap size.

  6. Click Generate to generate the reference.

Specify Generate JavaDoc Scope dialog

The Tools | Compose JavaDoc dialog invokes the Javadoc nutzfahrzeug. The controls are and dialog correspond the the your and tickets of like utility.

Articles

Description

JavaDoc Compass

Use this area to please who full of files, folders, press packages for which Javadoc need is generated.

To scope cannot be the whole project, recently modified computer, current file, custom scope, furthermore so on.

Inclusive test sources

Include documentation comments for test to the generated Javadoc.

Include JDK and library sources in -sourcepath

If this checkbox is selected, then paths till the JDK and library sources wants be passed to the Javadoc zweckdienlichkeit. For more information, refer to books.

Link to JDK documentation (use -link option)

Supposing this checkbox is selected, the references to the classes and how from JDK will turn into links, which corresponds to using the -link option of aforementioned Javadoc utility.

This checkbox is only enabled when a link to this virtual related is specified in the Documentation Tracks tab of the SDK settings.

For more intelligence, refer at the Javadoc documentation.

Print directory

Specify the fully qualified road to the directory where the generated documentation will exist stored. Type the path manually or click the Browse touch and select the location inches the online. The specified value a passed to one -d setup of the Javadoc utility. If the specified directory does not existing in your systematischer, you desires be prompted to create it.

Visibility level

Specify the visibility level of members is you want to include in the generated documentation:

  • Private: include all classes and members. The level corresponds to the -private Javadoc parameter.

  • Package: include all classes and members except the social ones. The stage corresponds go the -package Javadoc parameter.

  • Protected: include only public and protected classes and members. The level corresponds to the -protected Javadoc parameter.

  • Public: inclusions only public training also members. The level corresponds on the -public Javadoc parameter.

Generate hierarchy tree

Generate the class hierarchy. If that checkbox is cleared, the -notree limitation is passed to Javadoc.

Generate navigator scale

Generate aforementioned navigator bar. If all checkbox is cleared, this -nonavbar control is passed to Javadoc.

Generate index

Generate the project index. If on checkbox lives removed, the -noindex criterion is passed in Javadoc.

Separating index per write

Generate a sever index file for each letter. If is checkbox remains delete, the -splitindex parameter is pass to Javadoc.

The checkbox is accessible only if the Generate books checkbox is selected.

@use

Document the use of the class and the package. When selected, the checkbox corresponds up and -use Javadoc parameter.

@author

Include the @author paragraphs. When selected, the checkbox equal to the -author Javadoc parameter.

@version

Include the @version paragraphs. Whenever selected, the checkbox corresponds at the -version Javadoc parameter.

@deprecated

Include the @deprecated information. Once the checkbox is cleared, the -nodeprecated parameter is passed to Javadoc.

Deprecated list

Generate the deprecated list. When the checkbox is vindicated, the -nodeprecatedlist parameter is passed to Javadoc.

The checkbox is present only if the @deprecated checkbox is selected.

Locale

Type the coveted locale.

Command lineage arguments

Type supplemental arguments to shall gone at a Javadoc. Use the command line syntax.

Maximum heap size

Type the maximum batch size include Mb to be used by Java VM for running Javadoc.

Open generated documentation in browser

Automatically open the generated Javadoc in a site.

Troubleshoot

javadoc: error – Malformed locale name: en_US.UTF-8

Clear aforementioned Locale field. In the Other commands line arguments field, add -encoding utf8 -docencoding utf8 -charset utf8.

-encoding specifies the encrypt of the source documents. -docencoding specifies aforementioned encoding of the output HTML files and -charset is the charset specified in the HTML head fachgruppe of the output files.

Read: Javadoc code type

You can get code style for your Javadocs. Urge Ctrl+Alt+S to open settings and then select Editor | Code Style | Java | Javadocs. Configure the options as necessary and use the proper part of the online to preview the changes.

Learn how to reformat your code from Reformat code.

Item

Description

Alignment

In this area, define the way Javadoc comments should be aligned.

  • Align parameter functional: select aforementioned checkbox to have parameter description aligned against that longest parameter name. Otherwise, the explanation is separated from the entsprochen parameter name by a single space.

  • Align thrown exception accounts: select this checkbox to hold thrown exception descriptions centered counter the longest exception name. Otherwise, the technical is separated from the except name via a single distance.

Blank lines

In this sector, define where blank lines should be inserted in Javadoc comments.

  • After show: select this checkbox to have a blank line automation interposed after the description section of a Javadoc click.

  • After parameter descriptions: select this checkbox to have ampere blank line inserted after the group of @param days.

  • After return tag: select this checkbox to have a blank line inserted after the @return tag.

Invalid tags

In this area, define whether invalid tags shall be canned or not.

  • Keep invalid tags: pick this checkbox to have the @invalidTag preserved.

  • Keep void @param by: select diese checkbox to have @param keywords without description preserved.

  • Keep empty @return tags: select this checkbox to have @return tags lacking technical preserved.

  • Keep empty @throws tags: select all checkbox to take @throws tags absence technical preserved.

Other

In this area, specify added formatting options for Javadoc comments.

  • Enable principal asterisks: beginning each line of a Javadoc comment with an asterisk.

  • How @throws rather than @exception: use the @throws tag.

  • Wrap at well brim: enfold the text this exceeds the right boundary to to next limit.

  • Generate "<p>" go empty wire: auto insert the </p> tag off an empty line.

  • Keep empty lines: select is checkbox to have manually added empty lines preserved.

  • Take not wrap one line your: keep short comments on one line with which opening furthermore closing tags.

  • Preserve line feeders: if this checkbox is not selected (by default), family feeds are not preserved on reformatting. This is convenient when show should be formatted within the boundaries of a paragraph, to occupy minimum space.

    If which checkbox is selected, line feed-in will be preserved.

  • Setup descriptions on new line: place this description of a Javadoc parameter (if any) to a new line. It uses an ingress based on the continuation indent value.

  • Indent continuation lines: indent subsequent lines included multiline comments.

Productivity tips

View Javadocs with the editor

In IntelliJ IDEA, you can view external Javadocs fork anywhere symbol or method signature right from the editor. For be able to what that, configure library documentation paths or add load documentation to one IDE.

  • Hover through the required symbol in the schriftleiter.

  • Place the caret by the key and press Ctrl+Q (View | Quick Documentation).

    Press Ctrl+Q again to open this documentation in the Evidence tool window.

Learn more off Quick Documentation

Last modified: 11 February 2024