What’s mining: Advanced YARD support

Hello guys,

Not long ago we wrote about the coming YARD support in RubyMine, and today it’s time to share some more with you. So, what have been done since then. First, RubyMine supports any syntax of types annotations supported by YARD. More details can be found at http://yardoc.org/features.html.

You can annotate either return types or method parameters with types. Moreover you can use autocompletion for tag names, method parameters, types, anywhere you may need.  Of course complex namespaces and even alternative types are supported out of the box.

Let me show you some screenshots of all these features in action. Consider a small method with given content:

And if for some reason RubyMine hadn’t managed to compute a return type, it is pretty natural intention to add it manually. Now you can do it instantly.

You even get the autocompletion here.

Using intention actions you can create type annotations for any method parameter as well. But once you’ve made a mistake in parameter name or want to rename it for any other reason you get annotation renamed automatically. On the screenshot below you can see the familiar in-place rename for parameters and local variables.

All the tags are validated on the fly for duplications, wrong parameter names, etc., with quickfixes available.

That’s all about YARD support within the editor, however we have yet another feature related to YARD to share. As you know http://rubydoc.info uses YARD inside it to provide the information about classes, modules, methods, etc., and RubyMine uses this resource to show external documentation for almost everything, just navigate to the item and use either action View | External Documentation or a corresponding shortcut.

P.S. The last thing to mention is that parameter descriptions are show within Quick Documentation Popup.

Thanks for reading and stay tuned!

Develop with pleasure!
-JetBrains RubyMine Team

This entry was posted in Feature, WhatsMining and tagged , . Bookmark the permalink.

7 Responses to What’s mining: Advanced YARD support

  1. Adam Cooper says:

    Outstanding. Great work.

    Is it possible that, given type information in comments, RubyMine can alert us when it notices we’re using a type “incorrectly” (such as passing in a Hash instead of a Date, or treating the return value as a Hash instead of a Date)? Or would this just not make sense for Ruby?

  2. Oleg Shpynov says:

    Hello Adam,

    Of course this makes sence, it is not implemented yet. Using this kind of annotations RubyMine will be able to infer return types of methods in complex cases, and provide you with autocompletion and warnings in case of wrong usages. However feel free to submit feature requests at: http://youtrack.jetbrains.net/issues/RUBY

    Regards,
    Oleg

  3. I started using YARD recently, excellent timing! Will this be part of 3.1? 3.2? 4.0?

  4. Oleg Shpynov says:

    Hello J.Pablo,

    This will be included in the next major version of RubyMine.

    Regards,
    Oleg

  5. Kovalchuk Anatoliy says:

    Great Work!
    When are you going to add support YARD for views?
    It would be comfortably for partials with local variables

  6. Steve Benner says:

    I wish that YARD support included syntax highlighting for the tags and directives, as is provided for Rdoc. It seems like an easy thing to add, and would be so very helpful…

    P.S. I intend to open an issue of course, but currently the site is non-responsive (the error states that the server is overloaded!).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">