# Document code

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/ruby/2026.3/llms.txt).

[YARD](https://github.com/lsegal/yard) and [RDoc](https://github.com/ruby/rdoc) are the most popular documentation generation tools used in multiple libraries for documenting code. RubyMine allows you to [view documentation](viewing-reference-information.html) written in a YARD or RDoc syntax using Quick Documentation Lookup. Moreover, RubyMine provides extended capabilities to work with YARD tags:

* Create missing YARD tags

* Check the validity of YARD tags and fix them

* Utilize YARD tags for better code insight (for example, determining an object type, viewing parameter information for methods, and so on)

## Create and fix YARD tags

Here we'll show you how to document a method that takes several parameters. In our case, the method takes two arguments and returns the product of these values.

```RUBY
def multiply(val1, val2)
end
```

We'll see on how to annotate this method using YARD tags and fix incorrect tags.

Procedure: Add @param tag

1. Place a caret at the method name and press `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Alt+Enter` (Visual Studio), `⌥ ⏎` (Visual Studio (macOS)), `Alt+Enter` (TextMate), `Alt+Enter` (NetBeans), `Ctrl+1` (Eclipse), `⌘ 1` (Eclipse (macOS)).

2. In the invoked popup, select the Add @param tag action.

3. RubyMine will add the corresponding comment above the method and will suggest that you specify the type of each parameter value. Start typing Integer and then press `Ctrl+Space` (Windows), `⌃ Space` (macOS), `⌃ Space` (IntelliJ IDEA Classic (macOS)), `⌃ Space` (macOS System Shortcuts), `Ctrl+Space` (XWin), `Ctrl+Space` (GNOME), `Ctrl+Space` (KDE), `Alt+/` (Emacs), `Ctrl+Space` (Sublime Text), `⌃ Space` (Sublime Text (macOS)), `Ctrl+Space` (Visual Studio), `⌃ Space` (Visual Studio (macOS)), `Ctrl+Space` (TextMate), `Ctrl+Space` (NetBeans), `Ctrl+Space` (Eclipse), `⌃ Space` (Eclipse (macOS)) to view suggestions. Select Integer, press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (TextMate), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS)) to confirm your choice and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (TextMate), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS)) one more time to specify the type of the second parameter.

![Add param tags](https://resources.jetbrains.com/help/img/idea/2026.3/rm_annotate_method_param_tags.animated.gif)

Procedure: Configure syntax format for @param tag

By default, RubyMine generates the parameter name after the parameter type (for example, `@param [Integer] val1`). To change this behavior and set the parameter name before its type (`@param val1 [Integer]`), do the following:

1. Open the Settings dialog (`Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Meta+Comma` (TextMate), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS))).

2. Open the `Editor | Inspections` page and select the Method parameter missing '@param' tag inspection in the Ruby group.

3. Specify the desired order using the Tag syntax format option.

Procedure: Remove incorrect YARD tags

When you edit YARD tags, RubyMine checks whether or not any wrong tags exist. For example, this can be a duplicated tag or tag does not have a corresponding parameter in code. To remove an incorrect YARD tag:

1. Place the caret at the highlighted line containing the desired tag and press `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Alt+Enter` (Visual Studio), `⌥ ⏎` (Visual Studio (macOS)), `Alt+Enter` (TextMate), `Alt+Enter` (NetBeans), `Ctrl+1` (Eclipse), `⌘ 1` (Eclipse (macOS)).

2. In the invoked popup, select the Remove tag action.

![Remove a param tag](https://resources.jetbrains.com/help/img/idea/2026.3/rm_annotate_method_param_tag_remove.animated.gif)

## YARD for code insight

RubyMine utilizes YARD type annotations for various code insight features, for example, determining an object type, using the obtained object type in [code completion](auto-completing-code.html), viewing parameter information for methods, and so on. Let's see on several examples.

Procedure: View type info

RubyMine uses YARD tags such as `@return`, `@param`, or `@yieldparam`, to determine object types.

![View type info](https://resources.jetbrains.com/help/img/idea/2026.3/rm_yard_return_type_info.png)

Note that RubyMine suggests completion results corresponding to the specified type.

![Object type in completion](https://resources.jetbrains.com/help/img/idea/2026.3/rm_yard_return_type_completion.png)

> **Tip:**
> Apart from YARD tags, RubyMine can process the custom [@type](#add_type_tag) tag to receive information about the object type.

Procedure: Return/parameter type mismatch

RubyMine can check whether or not the actual return and parameter types for a method match corresponding types provided using the `@return` and `@param` annotations. For example, if the method return type does not match the `@return` type, the editor will show you a warning.

![Method return type mismatch](https://resources.jetbrains.com/help/img/idea/2026.3/rm_yard_return_type_mismatch.png)

You can manage these warnings using the  Mismatched parameter type and Mismatched return type [inspections](code-inspection.html).

Procedure: Parameter info

RubyMine understands the `@overload` tag and will suggest to you all the declared overloads when showing [parameter information](viewing-reference-information.html#view-parameter-info).

![Parameter info](https://resources.jetbrains.com/help/img/idea/2026.3/rm_yard_overload_parameter_info.png)

## @type tag

Apart from standard YARD and RDoc tags, RubyMine can process the @type tag to receive information about the variable type. For example, you can use this tag for local variables (with or without variable names) and block parameters:

* Local variables ```RUBY # @type [Integer] customer_id = 1 # @type [String] customer_name customer_name = "Andrew Fuller" ```

* Block parameters ```RUBY # @type [Integer] number [1, 2, 3].each do |number| puts "#{number}" end ```

## Render YARD/RDoc comments

RubyMine allows you to render YARD/RDoc comments in the editor. Rendered comments are easier to read, and they don't overload your code with extra tags. You can click links to go to the referenced web pages, or view [quick documentation](viewing-reference-information.html#inline-quick-documentation) for the referenced topics.

Regular view:

![YARD comments in the editing mode](https://resources.jetbrains.com/help/img/idea/2026.3/rm_yard_render_comments_disabled.png)

Rendered view:

![YARD comments in the rendered mode](https://resources.jetbrains.com/help/img/idea/2026.3/rm_yard_render_comments_enabled.png)

RubyMine also recognizes YARD macro extensions and provides general coding assistance for them. When rendering macros, RubyMine displays the macro data in place of its reference. This includes any variable substitutions that may be used in the macro data ($1, $2, and so on).

Regular view:

![YARD macros in the editing mode](https://resources.jetbrains.com/help/img/idea/2026.3/rm_yard_render_macros_disabled.png)

Rendered view:

![YARD macros in the rendered mode](https://resources.jetbrains.com/help/img/idea/2026.3/rm_yard_render_macros_enabled.png)

Procedure: Toogle a rendered view

1. Click ![Toggle rendered view](https://resources.jetbrains.com/help/img/idea/2026.3/app.gutter.javadocRead.svg) in the gutter next to the necessary documentation comment (or press `Ctrl+Alt+Q` (Windows), `⌃ ⌥ Q` (macOS), `⌃ ⌥ Q` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ Q` (macOS System Shortcuts), `Ctrl+Alt+Q` (XWin), `Ctrl+Alt+Q` (GNOME), `Ctrl+Alt+Q` (KDE), `Ctrl+Alt+Q` (Emacs), `Ctrl+Alt+Q` (Sublime Text), `⌃ ⌥ Q` (Sublime Text (macOS)), `Ctrl+K, V` (Visual Studio), `⌘ K, V` (Visual Studio (macOS)), `Ctrl+Alt+Q` (TextMate), `Ctrl+Alt+Q` (NetBeans), `Ctrl+Alt+Q` (Eclipse), `⌃ ⌥ Q` (Eclipse (macOS))) to toggle the rendered view; click ![](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.edit.svg) to edit the comment.

2. (Optional) To change the font size, right-click a comment in the editor and select Adjust Font Size from the context menu. Note that the rendered comments use the same font size as the quick documentation popup.

Procedure: Enable rendering comments by default

You can configure the IDE to always render comments in the editor.

* Right-click the icon in the gutter (![the Toggle Rendered View icon](https://resources.jetbrains.com/help/img/idea/2026.3/app.gutter.javadocRead.svg) or ![the Toggle Rendered View icon](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.edit.svg)) and enable the Render All option.

* Alternatively, in the Settings dialog `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Meta+Comma` (TextMate), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)), select `Editor | General | Appearance` and enable the Render documentation comments option.

To edit a rendered comment, click the  ![the Toggle Rendered View icon](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.edit.svg) icon in the gutter next to the comment.

## See also

### Procedures

[JSDoc comments](creating-jsdoc-comments.html)

