Rake, rdoc, and Windows

Herein is described a problem with using Rake's RDocTask on Windows, and a proposed workaround. The workaround works well enough, but does anybody else have a better one?

While prepping my latest project for gemhood, I came across a problem with the rdoc task when used on Windows XP: it didn't work. This is documented in a few old ruby-talk posts. (See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/118963?help-en and http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/118968 for some proposed solutions).

Even after fixing the problem by applying the patch described in 118968, there was still another problem: the rdoc.bat file (and all Windows batch files) only take up to nine arguments. Eight command line options are used by the rdoc command before the first file is even mentioned:

rdoc.bat -o html --main 'README' --title 'MyProjectName' -T 'html' README TODO lib/xx.rb lib/xx/file1.rb lib/xx/file2.rb ...

Here's what I have come up with: instead of the method proposed in 118968

     def rdoc
       RUBY_PLATFORM =~ /win32/ ? 'rdoc.bat' : 'rdoc'
     end

(and the associated change in RDocTask#define that calls this method), I use

     def rdoc
       return 'rdoc' unless RUBY_PLATFORM =~ /win32/
       require 'rbconfig'
       bindir = Config::CONFIG['bindir']
       return "#{File.join(bindir, 'ruby.exe')} #{File.join(bindir, 'rdoc')}"
     end

Will this work on all Windows systems, and is it the right thing to do? If so, is it an appropriate addition to Rake itself?

Jim

···

--
Jim Menard, jimm@io.com, http://www.io.com/~jimm
"This looks like a job for emergency pants!" -- Torg, www.sluggy.com

FYI under xp batch files support a %* notation to mean all the command
paramerters, so if rdoc.bat was changed from:

@echo off
"c:\ruby\bin\ruby.exe" "c:\ruby\bin\rdoc" %1 %2 %3 %4 %5 %6 %7 %8 %9

to:

@echo off
"c:\ruby\bin\ruby.exe" "c:\ruby\bin\rdoc" %*

would work better - I do not have older versions of Windows to check
this on - sry
Patrick

···

-------------------

@echo off
"c:\ruby\bin\ruby.exe" "c:\ruby\bin\rdoc" %*

On Fri, 25 Mar 2005 23:06:32 +0900, Jim Menard <jimm@io.com> wrote:

Herein is described a problem with using Rake's RDocTask on Windows, and a
proposed workaround. The workaround works well enough, but does anybody else
have a better one?

While prepping my latest project for gemhood, I came across a problem with the
rdoc task when used on Windows XP: it didn't work. This is documented in a few
old ruby-talk posts. (See
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/118963?help-en and
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/118968 for some
proposed solutions).

Even after fixing the problem by applying the patch described in 118968, there
was still another problem: the rdoc.bat file (and all Windows batch files)
only take up to nine arguments. Eight command line options are used by the
rdoc command before the first file is even mentioned:

rdoc.bat -o html --main 'README' --title 'MyProjectName' -T 'html' README TODO
lib/xx.rb lib/xx/file1.rb lib/xx/file2.rb ...

Here's what I have come up with: instead of the method proposed in 118968

     def rdoc
       RUBY_PLATFORM =~ /win32/ ? 'rdoc.bat' : 'rdoc'
     end

(and the associated change in RDocTask#define that calls this method), I use

     def rdoc
       return 'rdoc' unless RUBY_PLATFORM =~ /win32/
       require 'rbconfig'
       bindir = Config::CONFIG['bindir']
       return "#{File.join(bindir, 'ruby.exe')} #{File.join(bindir, 'rdoc')}"
     end

Will this work on all Windows systems, and is it the right thing to do? If so,
is it an appropriate addition to Rake itself?

Jim
--
Jim Menard, jimm@io.com, http://www.io.com/~jimm
"This looks like a job for emergency pants!" -- Torg, www.sluggy.com

Jim Menard wrote:

Herein is described a problem with using Rake's RDocTask on Windows, and a proposed workaround. The workaround works well enough, but does anybody else have a better one?

Why use a .bat file at all? The one click installer makes .rb files executable which means you needn't bother with bats.

[snip]

Even after fixing the problem by applying the patch described in 118968, there
was still another problem: the rdoc.bat file (and all Windows batch files)
only take up to nine arguments. Eight command line options are used by the
rdoc command before the first file is even mentioned:

rdoc.bat -o html --main 'README' --title 'MyProjectName' -T 'html' README TODO
lib/xx.rb lib/xx/file1.rb lib/xx/file2.rb ...

[snip]

use the "shift" batch file command - somethign like this:

···

On Fri, 25 Mar 2005 23:06:32 +0900, Jim Menard <jimm@io.com> wrote:
--------------------
set __RDOC__=%1 %2 %3 %4 %5 %6 %7 %8
shift
shift
shift
shift
shift
shift
shift
shift
set __firstfile__=%1
...
--------------------

see http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/shift.mspx

- Shad

--

----------

Please do not send personal (non-list-related) mail to this address.
Personal mail should be sent to polyergic@sterfish.com.

The primary reason I would guess is that necessity of typing:

rdoc.rb

as cmd is not all that smart and will not execute rdoc.rb, unless you
type it with the extension -- not a big deal when typing, but it would
do a real number on some scripts.

···

On Sat, 26 Mar 2005 02:19:49 +0900, linus sellberg <sellberg@google.com> wrote:

Jim Menard wrote:
> Herein is described a problem with using Rake's RDocTask on Windows, and
> a proposed workaround. The workaround works well enough, but does
> anybody else have a better one?

Why use a .bat file at all? The one click installer makes .rb files
executable which means you needn't bother with bats.

linus sellberg wrote:

Jim Menard wrote:

Herein is described a problem with using Rake's RDocTask on Windows, and a proposed workaround. The workaround works well enough, but does anybody else have a better one?

Why use a .bat file at all? The one click installer makes .rb files executable which means you needn't bother with bats.

I'm not sure if I'm the only one doing this, but I prefer my Ruby files getting opened in an editor when I double click them.

linus sellberg wrote:

Jim Menard wrote:

Herein is described a problem with using Rake's RDocTask on Windows, and a proposed workaround. The workaround works well enough, but does anybody else have a better one?

Why use a .bat file at all? The one click installer makes .rb files executable which means you needn't bother with bats.

I didn't create the .bat file. I assume the rdoc installation process did so. I'm just trying to work around the existing rdoc that came with the Windows one-click installer.

I don't have these problems on my Mac OS X box, but I'm not allowed to use a reasonable OS at work.

Jim

···

--
Jim Menard, jimm@io.com, http://www.io.com/~jimm
"Good code in perl is fine, but there's something about bad code in perl
that's worse than bad code in other languages, something very HP-Lovecraft-
mad-servants-of-the-elder-gods-chattering-in-the-extradimensional-
insect-language kind of bad that makes my head hurt when I have to read
it." -- Jish Karoshi in comp.lang.ruby

It will if you add ".rb" to the PATHEXT system environment variable.

Yura.

···

-----Original Message-----
From: Patrick Hurley [mailto:phurley@gmail.com]
Sent: March 25, 2005 13:14

The primary reason I would guess is that necessity of typing:

rdoc.rb

as cmd is not all that smart and will not execute rdoc.rb,
unless you type it with the extension -- not a big deal when
typing, but it would do a real number on some scripts.

Patrick Hurley wrote:

The primary reason I would guess is that necessity of typing:

rdoc.rb

as cmd is not all that smart and will not execute rdoc.rb, unless you

But it will!

As Iouri wrote, .rb is added to the PATHEXT which means that the extension isn't needed.