« Where's nbextras.org... | Main | Ruby Screenshot of... »

20070525 Friday May 25, 2007

Ruby Screenshot of the Week #12: Improved Ruby Documentation

One of the things I did this week was to rewrite the code which extracts documentation for all the core Ruby APIs (which are defined in the C Ruby implementation). This fixes some bugs where a method here and there were missing its documentation.

In doing so, I started looking at the actual IDE presentation of the documentation as well, and thought I could make it a lot more appealing. Without further ado, here's how the documentation looks now:

The most interesting part here is that the IDE now figures out whether portions of the documentation corresponds to Ruby code, and then presents it with syntax highlighting right there in the documentation popup. (I've also improved the way the method signatures are displayed so it should use less space and be more readable now, although that's harder to spot than if you compare before-and-after shots.)

Heres another example. This shows a migration in a Rails application, where you're getting code completion on the create_table method.

One interesting aspect of this highlighting is that it's easier to spot mistakes in your comments. As I was testing this feature, I pulled up the documentation on the Rails send_file method - and the following code fragment looked wrong:

Sure enough, it looks like it's missing a single-quote right after 404.html. This is the kind of thing which will be a lot easier to spot and fix with the new enhanced highlighting!

P.S. You don't have to use code completion to get the documentation popup - just hit Ctrl-Shift-Space with the caret on the symbol you want to look up - or Command-Shift-Space on the Mac.

(P.S.2: If you're trying to download this, see my other blog entry on the current temporary download location.)

(2007-05-25 15:01:53.0) Permalink Comments [18]

Comments:

tor, been using the netbeans ruby plugin all week, and just moved to the special ruby ide build. good stuff. please take all this as positive in the big picture, because i am a fan of netbeans (used off and on for years) and definately appreciate the work you guys are doing for ruby... 1. my attr_accessor|_reader|_writer 's symbol definitions are not picked up by the code completion. at least they are not picked up in a method def when i type @<ctrl-space>, i get no help. previously used or initialized instance variables do appear to be picked up. class variables (e.g. @@a='hello') do not appear to be picked up by code completion either. 2. how are you prioritizing the code completion list. if i create two simple classes, A and B. on A i define 'test' method. now i go into B and create a method 'testA'. in there, i say "a = A.new". the next line i type a.<ctrl space>. i get a huge list. i the programmer have added one method to A. i would think that would appear at the top or would have some priority. i think a quick user study would reveal some better ordering algorithm. i also think fading would be helpful. i'd really like to see those kernel methods a very faint grey. there must be some way to enhance the signal to noise. 3. Same two simple classes as above. on class def B, i define a B.test method that simple prints 'tested'. outside of class B, in my main.rb, i type B.<ctrl-space> i do not see the class method 'B.test' i have defined. i try B::<ctrl-space> and still do not see it. 4. if i type require<space><ctrl-space>i get a very weird list of choices. it isn't until i type require '<ctrl-space> that i get the actual list of valid candidates. not a big deal, but you could pop the other list up and quote the choice for the user. are you interested in usability opinions? i have noticed quite a bit of inconsistencies in the general use of netbeans.

Posted by jherber on May 25, 2007 at 05:45 PM PDT #

ugh.. your blog throws out whitespace..

Posted by jherber on May 25, 2007 at 05:46 PM PDT #

Thanks for your comment! Yes, I'm definitely interested in usability opinions. There are many feedback channels; see http://wiki.netbeans.org/wiki/view/RubyFeedback.

Regarding your code completion feedback; I have filed an issue on your behalf - issue 104884. Regarding attribute completion, yep - that's already a known problem and something I'll address very soon; all the attributes are already in the index, I just have to improve the queries.

Posted by Tor Norbye's Weblog on May 25, 2007 at 07:23 PM PDT #

Another milestone. Congrats, Tor!
I have been filing issues to NBM issuezilla these days, so I won't litter your blog space. But please do look into those and if in-appropriate feel free to close them. Some of issues I filed were against wrong scripting engine i guess.

Posted by hemant kumar on May 26, 2007 at 01:44 AM PDT #

Error while opening of RHTML files
org.netbeans.api.languages.LanguageDefinitionNotFoundException: Language definition for text/x-ruby not found.
	at org.netbeans.modules.languages.LanguagesManager.getLanguage(LanguagesManager.java:93)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.readEmbeddings(LLSyntaxAnalyser.java:296)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.readNoGrammar(LLSyntaxAnalyser.java:371)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.readEmbeddings(LLSyntaxAnalyser.java:337)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.read2(LLSyntaxAnalyser.java:236)
	at org.netbeans.modules.languages.parser.LLSyntaxAnalyser.read(LLSyntaxAnalyser.java:112)
	at org.netbeans.modules.languages.ParserManagerImpl.parse(ParserManagerImpl.java:295)
	at org.netbeans.modules.languages.ParserManagerImpl.parseAST(ParserManagerImpl.java:246)
	at org.netbeans.modules.languages.ParserManagerImpl.access$000(ParserManagerImpl.java:67)
	at org.netbeans.modules.languages.ParserManagerImpl$1.run(ParserManagerImpl.java:158)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:539)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:964)

Posted by hemant kumar on May 26, 2007 at 02:26 AM PDT #

Hi Hemant, thanks - that bug has already been found by QA - it's issue 104862. I'll ping the responsible engineer to see what can be done about it. I just tried it myself and it definitely looks higher priority than it was at.

For those other bugs - what is your netbeans.org username? With that I can query for your issues - even those filed in other categories.

Posted by Tor Norbye's Weblog on May 26, 2007 at 10:03 AM PDT #

FYI - I've updated the build page (http://wiki.netbeans.org/wiki/view/RubyInstallation) with a link to a new build which has a workaround for the RHTML issue (and the OSX icon is corrected - I'll get to the other packaging stuff later.)

Posted by Tor Norbye on May 26, 2007 at 08:37 PM PDT #

Nice! Glad to see the "Go to File" feature added. It does seem somewhat flakey though, the wildcarding usually doesn't work right. I have a controller called "amazon controller.rb". When I type "*controller" I get "no files found". I probably have 30 files that match that pattern. If don't use wildcards, it does seem to work correctly. Couple other thoughts. I'm a huge IntelliJ fan so there are some features I miss: 1) Open Class (works like Go to File but for classes) 2)duplicate line (ctrl -D in intellij) - it's really suprising how often dupe line comes in handy! 3) IntelliJ's bookmarks are SO MUCH BETTER: CTRL-SHIFT-1 sets bookmark #1 at the current location, CTRL-1 goes there. CTRL-SHIFT-2 sets a second bookmark, CTRL-2 goes there. etc. This is great when you find yourself swtiching back and forth from several locaitons in the code (which I find is quite often) 4) the comment functionality of eclipse and IJ are superior: ctrl slash toggles between commented/uncommented. You have surpassed IJ for Ruby support by quite a bit now though, that's why I'm using NetBeans now - at least for Ruby. Great work!

Posted by phil swenson on May 26, 2007 at 11:07 PM PDT #

Thanks a lot for your job, Tor!! Just wanted to ask, is there a haml support in your task list? (with Go to Rails Action/View possibility) :) Great work!! thank s again.

Posted by Roman Melnik on May 27, 2007 at 12:31 AM PDT #

My NBM issuezilla handle would be gnufied.

Posted by hemant kumar on May 27, 2007 at 08:29 AM PDT #

Tor, I found some nasty issues with plugin installation modules. Ability to install downloaded plugins is total broken with 1386. Please have a look at ticket # 105122

Posted by hemant kumar on May 30, 2007 at 05:01 AM PDT #

Phil, thanks for the detailed feedback. I've forwarded your comments regarding the generic IDE level stuff (go to file, bookmarks, duplicate line, comment/uncomment) to the netbeans feedback alias. I will be providing Open Class soon - see http://blogs.sun.com/tor/entry/saturday_morning_hack for a temporary download location.

Roman, yes, HAML support is on there, but unfortunately not near the top. There is some preliminary work on it done by Jan Jancura in CVS under languages/haml, but I don't think it's in useable state yet.

Hemant, thanks for the report. I've reassigned that particular bug to the engineer responsible for auto update / the plugin manager. Keep them coming!

JHerber, I've just integrated a fix for your issue #4. Also, my patch for the code completion dialog issues on the Mac (clicking would cause it to disappear) was just applied this morning so the most recent builds should be more Mac+mouse friendly.

Thanks for your feedback everybody!

Posted by Tor Norbye's Weblog on May 30, 2007 at 10:20 AM PDT #

Hi, Tor! I've heard about FastRI - that is much faster and smarter than ri - may be it would be interesting for you http://eigenclass.org/hiki/fastri

Posted by freeman on June 03, 2007 at 05:43 PM PDT #

...some features I miss: 1) Open Class (works like Go to File but for classes) 2)duplicate line (ctrl -D in intellij).... 1) look for "Go to type" plugin (hack for ruby mode). it does open classes. 2) there is such function, and even better -- you can duplicate a line above the cursor line or beneath it. Look at Options->Keymap->Other to find what hotkeys you have and redefine it to ctrl+d, the functions called "Copy Selection else line up" and "Copy Selection else line down". And one more vote for "toggle comments" feature :) btw, if I ever mistakenly commented out a line twice and use 'uncomment' hotkey then, rubyide on win hugs :(

Posted by Vladimir Oleynik on June 04, 2007 at 05:52 AM PDT #

...some features I miss: 1) Open Class (works like Go to File but for classes) 2)duplicate line (ctrl -D in intellij).... 1) look for "Go to type" plugin (hack for ruby mode). it does open classes. 2) there is such function, and even better -- you can duplicate a line above the cursor line or beneath it. Look at Options->Keymap->Other to find what hotkeys you have and redefine it to ctrl+d, the functions called "Copy Selection else line up" and "Copy Selection else line down". And one more vote for "toggle comments" feature :) btw, if I ever mistakenly commented out a line twice and use 'uncomment' hotkey then, rubyide on win hugs :(

Posted by Vladimir Oleynik on June 04, 2007 at 05:53 AM PDT #

Thanks, Vladimir! I've gone to Options->Keymap->Other, and set ctrl+shift+c for the Remove trailing spaces.. and after that i've done the macros - which reformats code and then removes trailing spaces - and gave it alt+space shorcut - it's amazing.. i more and more love this IDE :)

Posted by freeman on June 04, 2007 at 04:49 PM PDT #

Tor, something worng with the blog's comments, when one posts a comment, it doesn't show, but the comment of the next user will shift the previous comment, so it shows, but with wrong author.

Posted by Vladimir Oleynik on June 05, 2007 at 02:40 AM PDT #

Oh, sorry, disregard my previous post :(

Posted by Vladimir Oleynik on June 05, 2007 at 02:42 AM PDT #

Post a Comment:

Comments are closed for this entry.