Documenting Source Code in IntelliJ IDEA
In this part:
IntelliJ IDEA provides convenient features for creating documentation comments.
Documentation comments in your source code are available for the Quick Documentation Lookup and open for review on pressing Ctrl+Q.
In Java files, IntelliJ IDEA creates stubs of documentation comments on typing the opening tag and pressing Enter.
If this feature applies to the methods,
tags are created for each parameter declared in the method signature,
tag is created if the method is not void, and
tags are created for each exception statement.
When you create additional tags, IntelliJ IDEA provides code completion that suggests the possible tag names.
If a certain tag has multiple values, the same code completion provides the list of available values. Smart type code completion suggests the list of classes that are appropriate for the specific exception.
Documentation comments can be created in accordance with the syntax, selected in the
Python Integrated Tools page of the Settings/Preferences dialog, for example,
If this feature applies to a function, IntelliJ IDEA generates tags, depending on the selected docstring format, for example:
- For reStructuredText:
:paramtags for each parameter declared in the function signature, and
- For epytext:
@paramtags for each parameter declared in the function signature, and
If configured, the documentation
comment stubs can be generated with
In the Python files, IntelliJ IDEA recognizes the documentation comments represented as Python docstrings.
Before you start, make sure that the required docstring format, for example,
reStructuredText, is selected in the
Python Integrated Tools page of the Settings/Preferences dialog.
Also note that IntelliJ IDEA captures custom roles from
When configuring the directory that contains
*.rst files, point to the
Integrated Tools | Path to the directory with *.rst files).
RDoc tags are completed:
YARD tags are completed:
- YARD directives complete in places where methods could be defined;
- Type annotations complete where applicable (assignments, before block vars);
param/return/etc.tags complete before methods, inside directive docstrings, before
Besides documentation comments in the RDoc and YARD formats, IntelliJ IDEA supports HEREDOCS. This is especially useful, if you are writing large blocks of text.
For example, consider the following:
If you perform run, the lines between <<-HEREDOC and HEREDOC appear in the Run tool window.