IntelliJ IDEA 2017.2 Help

Creating JSDoc Comments

This feature is supported in the Ultimate edition only.

On this page:


To make your code easy to use by other developers it is considered good practice to provide an HTML documentation of its Application Programming Interface (API). Such documentation can be generated automatically by the JSDoc tool. All you need, is supply your code with documentation comments in accordance with the JSDoc standard. The tool retrieves information from your comments and renders it in HTML using a built-in template.

You can find a detailed description of the JSDoc syntax with examples and explanation of their use in the article An Introduction to JSDoc.

IntelliJ IDEA creates stubs of JSDoc comments on typing the opening tag /** and pressing Enter. If this feature is applied to a method or a function, @param tags are created. In any other places IntelliJ IDEA adds an empty documentation stub.

TODO patterns and Closure Compiler annotations inside documentation comments are also recognized and are involved in code completion, intention actions, and other types of coding assistance.

Documentation comments in your source code are available for the Quick Documentation Lookup and open for review on pressing Ctrl+Q.

IntelliJ IDEA checks syntax in the comments and treats it according to the Code Inspections settings.

Example of JavaScript comment

Consider the following function:

function loadDocs(myParam1, myParam2){}

Type the opening documentation comment and press Enter to generate the documentation comment stub:

/** * @param myParam1 * @param myParam2 */

Enabling documentation comments

  1. Open the Editor | General | Smart Keys page of IntelliJ IDEA settings (Ctrl+Alt+S).
  2. In the Enter section, select or clear Insert documentation comment stub check box.
  3. The following is only valid when Python Plugin is installed and enabled!

    For Python, scroll to the Insert type placeholders in the documentation comment stub option and select or clear the check box as required. Refer to the option description for details.

Creating a JSDoc comment block

  1. Place the caret before the method or function declaration.
  2. Type the opening block comment /** and press Enter.
  3. Describe the listed parameters and return values.

Documentation comment can be created with the dedicated action Fix Doc Comment. It can be invoked by means of Find Action command.

Press Ctrl+Shift+A, with the caret somewhere within a class, method, function, or field, which should be documented, and enter the action name Fix Doc String. The missing documentation stub with the corresponding tags is added. For example:

/** * * @param userInput * @return */ static boolean processRepeatConversion (@NotNull String userInput) { boolean repeatConversion = false; if (((userInput.equals("y")) || (userInput.equals("Y")))) { repeatConversion = true; } return repeatConversion; }

The next case lays with fixing problems in the existing documentation comments.

For example, if a method signature has been changed, IntelliJ IDEA highlights a tag that doesn't match the method signature, and suggests a quick fix.

For JavaScript, IntelliJ IDEA suggests an intention action UpdateJSDoc comment. You can also press Ctrl+Shift+A, and type the action name:

fix doc comment
Last modified: 29 November 2017

See Also