Generate Ruby on Rails CHM Documentation

Ruby on Rails 11 Comments »

Update April 21, 2008: Delynn Berry now has a new CHM file up for Rails version 2.0.2 with a much better index and fewer broken links than what I was able to create. Get it here.

CHM (compiled HTML Help) is arguably one of the better Microsoft inventions and generating these files from Ruby on Rails documentation is should be easy using Rdoc.
A general article on the different ways of generating Rails offline documentation is here.

The Rdoc approach is described in this article:

http://wiki.rubyonrails.org/rails/pages/HowToGenerateChmForRails

Older (and possibly newer in the future) CHM files created using this technique are here: http://delynnberry.com/projects/rails-chm-documentation

These are the basic rdoc instructions:

The core command is:

rdoc -f chm -o chm_folder action* rails-*

which you have to run in

C:\ruby\lib\ruby\gems\1.8\gems\

(assuming c:\ruby is your ruby directory).

You might (or will likely) get this error:

rails-2.0.1/lib/rails_generator/generators/components/controller/templates/controller.rb:3:15: Expected class name or ‘<
<’. Got RubyToken::TkLT: “<”

This is the offending file:

C:\ruby\lib\ruby\gems\1.8\gems\rails-2.0.2\lib\rails_generator\generators\components\controller\templates\controller.rb

You can exclude this file by altering the command like so:

rdoc -f chm -o chm_folder action* rails-* -x controller.rb

It should then run up to this point.

Generating CHM…
C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1293:in `initialize’: Invalid argument - classes/<.html (Errno::EINVAL)
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1293:in `open’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1293:in `gen_into’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1289:in `each’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1289:in `gen_into’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1277:in `generate_html’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/html_generator.rb:1197:in `generate’
        from C:/ruby/lib/ruby/1.8/rdoc/generators/chm_generator.rb:38:in `generate’
        from C:/ruby/lib/ruby/1.8/rdoc/rdoc.rb:284:in `document’
        from C:/ruby/bin/rdoc:62

This is quite hard to work around and some suggest you should just compile help for the action* packages:

rdoc -f chm -o chm_folder action*

which contain enough documentation to get by with most daily tasks.

Update March 2, 2008: The technique described by Michael in the comments using the command

rdoc -f chm -o chm_folder action* rails-* -x template/*

works fine to create a chm file. However, I use this technique only to create the index.hhk file which I then use in the following HTML Help “manual” process, which IMHO leads to a better linked document and nicely inlined source code:

  1. Download the Rails Project files from here: http://rubyforge.org/frs/?group_id=307 and unzip to your hard drive.
  2. Download HTML Help Workshop and install (which you need for the above rdoc technique as well).
  3. Start HTML Help Workshop and create a new project:

image

Give it a descriptive name (damn, is that a real wizard on the left?!; I guess those were the good old days):

image

In the Existing Files step, select just HTML files:

image

Click add:

image

Navigate to the <folder you unzipped rails to>\rails\doc\api:

image

Select only the index.html file:

image

The project is created.

Go to the Contents tab:

image

Give it a name and save:

image

Optionally do the same for index (I haven’t had any luck generating an index file).

Update March 2, 2008: Simply navigate to the index.hhk file generated using the

rdoc -f chm -o chm_folder action* rails-* -x template/*

command. This index will work only partly and many links will be dead but many work, so…

Set the project options as follows:

image

Make sure the Default file is set to “index.html”, not the full path:

image

Select “Automatically create content file (.hhc) when compiling”:

image

I was so far unable to create an index, so checking “Include keywords from HTML files” has no effect for me.

Set “Compile full-text search information”:

image

Fire “Save all and compile”. You should get a searchable CHM file with the Rails documentation.

image

Here is the resulting CHM file, now with (rudimentary and flaky) index. Enjoy.

Update March 2, 2008: I’ve uploaded a new version of the CHM file, now with an index I generated with the technique described by Michael (see comments below). However, the index works only party, many links are broken. But it’s better than nothing I guess.

And finally, some non-Windows CHM readers (thanks to Delynn Berry):

Happy New Year Everyone!

del.icio.us Tags: ,
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

HP is Reviving the Pocket PC

Pocket PC and Windows Mobile 3 Comments »

News of the imminent death of the Pocket PC were slightly exaggerated it seems.
HP is making a wise decision to revive the stand-alone Pocket PC device without phone software or hardware with two new models:

The iPAQ 110 (identical iPAQ 111, in Europe it’s called the iPAQ 114) and 220 are the first full (3.5 inch) screen Pocket PCs without phone functionality to be released in about 2 years. The 110 is already out, PocketPCCentral has an extensive review which has this quote:

Today, there may be a bit of a reawakening of the iPAQ, or at least an attempt at one, as HP has announced two new Windows Mobile PDAs without built-in phones.

The device is similar to the rx1950 of yore, weighing in at just 3.5oz and with the added goodies of 802.11g support as well as Bluetooth and many other new features. The unit retails for about US$ 300 and approximately the same in Euros.

The iPAQ 210 announced for early next year will even features a full VGA (640×480) display, making it even better as a handheld PDF reader which, unlike the Amazon Kinlde, will have mature PDF support as well as a backlit display. From this review:

For a long while, it seemed the standalone Windows Mobile PDA, or Pocket PC, was a thing of the past.  Now, HP is giving new hope for those who want a separate PDA and phone with an upcoming iPAQ 210 Enterprise Handheld which is just such a dedicated PDA device, offering a powerful Windows Mobile device without phone hardware or software.

It’s heartening to see the Pocket PC revived as it’s such a useful gadget not for the hardware (no phone, duh) but for the huge canon of software created over the past few years. Now if we’d just see a comeback of the Palm to get some new competition going in this space.

Tags:
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Using Regular Expressions in MS SQL Server 2005

SQL No Comments »

Regular Expressions are an extremely powerful tool for parsing and querying textual data; so using them in a database environment looks like a good match. But DBMS vendors have been rather slow building RegEx functionality into their offerings. Oracle has it since 10g and some open source databases also have a head start.

Microsoft obviously put the emphasis on XML/XPath since SQL Server 2000, and regular expression support is not on the horizon, even for SQL Server 2008.

A MSDN article gives you all you need to get you started with regular expressions in SQL Server 2005. Be sure to download the source code which includes a sample project. You have to set the database connection in the project properties and then start debugging. The assembly will then be automatically deployed to the server and you’ll have regular expression support via CLR user-defined functions. You must have the compatibility level set at 90 (SQL Server 2005), so you better be absolutely sure that sp_dbcmptlevel won’t break your stored procedures. Good luck!

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Mongrel Errors: already initialized constant OPTIONS

Ruby on Rails 1 Comment »

Errors like

/opt/software/ruby/gems/rails-1.2.5/lib/commands/servers/mongrel.rb:15: warning: already initialized constant OPTIONS
/opt/software/ruby/gems/rails-1.2.5/lib/commands/servers/mongrel.rb:18: undefined method `options’ for []:Array (NoMethodError)

when starting Mongrel or Webrick with ruby script/server are likely plugin related. You might be tempted to fire up the debugger, especially since the newly released Netbeans IDE makes debugging Rails apps almost enjoyable. However, the debugger is unlikely to help much here as the error messages don’t describe the actual problem, which is missing gem dependencies of some plugin.
It’s much easier and quicker to proceed as suggested in this article:
Move all plugin files from $RAILS_ROOT/vendor/plugins to a different directory. Then the web server should boot already. Then you can move the plugins back one by one and then test and see if you need any additional gems or other dependencies. Hope it helps.




[Slashdot]
[Digg]
[Reddit]
[del.icio.us]
[Facebook]
[Technorati]
[Google]
[StumbleUpon]
	  
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in