Rake, rdoc, and Windows

Discussion in 'Ruby' started by Jim Menard, Mar 25, 2005.

  1. Jim Menard

    Jim Menard Guest

    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, , http://www.io.com/~jimm
    "This looks like a job for emergency pants!" -- Torg, www.sluggy.com
     
    Jim Menard, Mar 25, 2005
    #1
    1. Advertising

  2. 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 <> 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, , http://www.io.com/~jimm
    > "This looks like a job for emergency pants!" -- Torg, www.sluggy.com
    >
    >
     
    Patrick Hurley, Mar 25, 2005
    #2
    1. Advertising

  3. 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, Mar 25, 2005
    #3
  4. 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 <> 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.
    >
    >
     
    Patrick Hurley, Mar 25, 2005
    #4
  5. > -----Original Message-----
    > From: Patrick Hurley [mailto:p]
    > 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.
     
    Iouri Kloubakov, Mar 25, 2005
    #5
  6. 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.
     
    linus sellberg, Mar 25, 2005
    #6
  7. 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.
     
    Florian Gross, Mar 26, 2005
    #7
  8. Jim Menard

    Jim Menard Guest

    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, , 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
     
    Jim Menard, Mar 28, 2005
    #8
  9. On Fri, 25 Mar 2005 23:06:32 +0900, Jim Menard <> 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/shift.mspx


    - Shad



    --

    ----------

    Please do not send personal (non-list-related) mail to this address.
    Personal mail should be sent to .
     
    Shad Sterling, Mar 28, 2005
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kelly Felkins
    Replies:
    1
    Views:
    125
    Jim Weirich
    Apr 5, 2006
  2. peppermonkey
    Replies:
    1
    Views:
    270
    Gregory Brown
    Feb 10, 2007
  3. James Mead
    Replies:
    0
    Views:
    161
    James Mead
    Jan 15, 2008
  4. John Feminella
    Replies:
    0
    Views:
    262
    John Feminella
    Apr 25, 2010
  5. Pablo Yanez
    Replies:
    0
    Views:
    123
    Pablo Yanez
    May 2, 2011
Loading...

Share This Page