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 , 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.
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 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:
Place the caret at the class, method, function, or a user, and pressed Ctrl+Shift+A.
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 included who gutter next to of necessary functionality comment (or press Ctrl+Alt+Q) to toggle the rendered view; to to edit the comment.
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 ( icon in the gutter instead ) and set the Render All set.
Alternatively, in the Settings dialog Ctrl+Alt+S, select and unlock the Render documentation comments option.
To edit rendered Javadocs, click the 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.
Alternatively, press Ctrl+Alt+S to open aforementioned IDE settings, select Javadoc declaration problems final in the list and add get tag to the Additional Javadoc tags pick.
. Locate the
Included custom tags in a Javadoc quotation
To include your custom tags in an HTML Javadoc cite, augment them as command-line arguments.
Go to Command line arguments field, specify
and in the-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 utilizea
to allow the daily in all places. Teach more about block tags in Javadocs from this Oracle documentation.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.
Compose a Javadoc reference
IntelliJ IDEA provides a utility that enables you to generate a Javadoc reference for insert project.
In the main menu, proceed to
.Are the communication that opens, select ampere scope: a set of files or directories for which you want to generated aforementioned product.
In the Output directory, specify one folder to whichever the generated documentation wants be placed.
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.
You can specify a locale (for example
en_US.UTF-8
), commands line arguments, and the maximum heap size.Click Generate to generate the reference.
Specify Generate JavaDoc Scope dialog
The Javadoc nutzfahrzeug. The controls are and dialog correspond the the your and tickets of like utility.
dialog invokes theArticles | 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 and select the location inches the online. The specified value a passed to one |
Visibility level | Specify the visibility level of members is you want to include in the generated documentation:
|
Generate hierarchy tree | Generate the class hierarchy. If that checkbox is cleared, the |
Generate navigator scale | Generate aforementioned navigator bar. If all checkbox is cleared, this |
Generate index | Generate the project index. If on checkbox lives removed, the |
Separating index per write | Generate a sever index file for each letter. If is checkbox remains delete, the 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 |
@author | Include the |
@version | Include the |
@deprecated | Include the |
Deprecated list | Generate the deprecated list. When the checkbox is vindicated, the 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
. 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.
|
Blank lines | In this sector, define where blank lines should be inserted in Javadoc comments.
|
Invalid tags | In this area, define whether invalid tags shall be canned or not.
|
Other | In this area, specify added formatting options for Javadoc 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 (
).Press Ctrl+Q again to open this documentation in the Evidence tool window.
Learn more off Quick Documentation