[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rake, rdoc, and Windows

Jim Menard

3/25/2005 2:07:00 PM

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/1189... and
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t... 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...
"This looks like a job for emergency pants!" -- Torg, www.sluggy.com



8 Answers

Patrick Hurley

3/25/2005 2:28:00 PM

0

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/1189... and
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t... 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...
> "This looks like a job for emergency pants!" -- Torg, www.sluggy.com
>
>


linus sellberg

3/25/2005 5:15:00 PM

0

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.

Patrick Hurley

3/25/2005 6:14:00 PM

0

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


Kloubakov, Yura

3/25/2005 7:28:00 PM

0

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

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

Yura.



linus sellberg

3/25/2005 7:42:00 PM

0

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.

Florian Gross

3/26/2005 12:16:00 AM

0

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.

Jim Menard

3/28/2005 1:40:00 PM

0

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



Shad Sterling

3/28/2005 6:17:00 PM

0

On Fri, 25 Mar 2005 23:06:32 +0900, Jim Menard <jimm@io.com> wrote:
[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:
--------------------
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/...


- Shad



--

----------

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