Rake, rdoc, and Windows

J

Jim Menard

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
 
P

Patrick Hurley

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
 
L

linus sellberg

Jim said:
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.
 
P

Patrick Hurley

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.
 
I

Iouri Kloubakov

-----Original Message-----
From: Patrick Hurley [mailto:p[email protected]]
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.

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

Yura.
 
L

linus sellberg

Patrick said:
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.
 
F

Florian Gross

linus said:
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.
 
J

Jim Menard

linus said:
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, (e-mail address removed), 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
 
S

Shad Sterling

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:
--------------------
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top