having problems fiddling with rake

Discussion in 'Ruby' started by Rich Morin, Mar 8, 2007.

  1. Rich Morin

    Rich Morin Guest

    I'm trying to get "rake doc:app" pull its input from a different
    Rails app's source tree. In trying to prototype a solution, I've
    fiddled with documentation.rake. However, my hack isn't working:

    > rake aborted!
    > stack level too deep
    > /usr/local/lib/ruby/gems/1.8/gems/
    > rake-0.7.1/lib/rake.rb:1038:in `orig_include'
    > rake-0.7.1/lib/rake.rb:1036:in `orig_include'
    > rails-1.2.2/lib/tasks/documentation.rake:41:in `include'


    My trace of the value being mapped contains only a series of:

    new_name='.//'


    Any idea what I'm doing wrong? Here's the relevant code:

    # /usr/.local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb defines
    # the include method, as follows:
    #
    # # Add file names defined by glob patterns to the file list.
    # # If an array is given, add each element of the array.
    # #
    # # Example:
    # # file_list.include("*.java", "*.cfg")
    # # file_list.include %w( math.c lib.h *.o )
    # #
    # def include(*filenames)
    # # TODO: check for pending
    # filenames.each do |fn|
    # if fn.respond_to? :to_ary
    # include(*fn.to_ary)
    # else
    # @pending_add << fn
    # end
    # end
    # @pending = true
    # self
    # end
    # alias :add :include
    #
    #####
    #
    # We can redefine this to add an arbitrary prefix to each path, based
    # on the RDOC_SRC_DIR environment variable:

    class FileList

    @@rdoc_src_dir = ENV['RDOC_SRC_DIR']

    if (@@rdoc_src_dir)
    alias :eek:rig_include :include

    def include(*filenames)
    list = filenames.map do |name|
    new_name = "#{@@rdoc_src_dir}/#{name}"
    puts "new_name='#{new_name}'" #T
    end
    orig_include(list)
    end
    alias :add :include
    end
    end
    ...


    More generally, if someone has a better way to solve the original
    problem, I'd be happy to hear about it!

    -r
    --
    http://www.cfcl.com/rdm Rich Morin
    http://www.cfcl.com/rdm/resume
    http://www.cfcl.com/rdm/weblog +1 650-873-7841

    Technical editing and writing, programming, and web development
     
    Rich Morin, Mar 8, 2007
    #1
    1. Advertising

  2. Rich Morin

    Jim Weirich Guest

    Rich Morin wrote:
    > Any idea what I'm doing wrong? Here's the relevant code:
    > class FileList
    >
    > @@rdoc_src_dir = ENV['RDOC_SRC_DIR']
    >
    > if (@@rdoc_src_dir)
    > alias :eek:rig_include :include
    >
    > def include(*filenames)
    > list = filenames.map do |name|
    > new_name = "#{@@rdoc_src_dir}/#{name}"
    > puts "new_name='#{new_name}'" #T

    ^^^^
    > end
    > orig_include(list)
    > end
    > alias :add :include
    > end
    > end
    > ...


    Puts doesn't return a useful value for +map+ to use.

    That being said, I don't see why you don't just duplicate the rails
    doc:app task and replace the filelists with what you need. It is
    probably less code than what you've invested in hacking FileList#include
    and it will be much less error prone.


    -- Jim Weirich

    --
    Posted via http://www.ruby-forum.com/.
     
    Jim Weirich, Mar 8, 2007
    #2
    1. Advertising

  3. Rich Morin

    Rich Morin Guest

    At 4:27 AM +0900 3/9/07, Jim Weirich wrote:
    > Puts doesn't return a useful value for +map+ to use.


    Point taken, but it didn't work even without the puts. So,
    my Ruby question remains...

    > That being said, I don't see why you don't just duplicate
    > the rails doc:app task and replace the filelists with
    > what you need. It is probably less code than what you've
    > invested in hacking FileList#include and it will be much
    > less error prone.


    I have considered that and may end up doing so, but it would
    mean tracking the changes to the original task, which is the
    kind of maintenance sinkhole I try to avoid.

    -r
    --
    http://www.cfcl.com/rdm Rich Morin
    http://www.cfcl.com/rdm/resume
    http://www.cfcl.com/rdm/weblog +1 650-873-7841

    Technical editing and writing, programming, and web development
     
    Rich Morin, Mar 8, 2007
    #3
  4. Rich Morin

    Jim Weirich Guest

    Rich Morin wrote:
    > I have considered that and may end up doing so, but it would
    > mean tracking the changes to the original task, which is the
    > kind of maintenance sinkhole I try to avoid.


    The original task uses a rake standard RDocTask. Of the six lines that
    configure it, three consist of selecting the right files (which is the
    part you want to change) and the other three set the document directory,
    the title and a few options.

    Doesn't seem to be too onerous.

    Now, duplicating the "doc:rails" task would be another issue.

    -- Jim Weirich



    --
    Posted via http://www.ruby-forum.com/.
     
    Jim Weirich, Mar 8, 2007
    #4
  5. Rich Morin

    Rich Morin Guest

    At 4:48 AM +0900 3/9/07, Jim Weirich wrote:
    > The original task uses a rake standard RDocTask. Of
    > the six lines that configure it, three consist of
    > selecting the right files (which is the part you want
    > to change) and the other three set the document
    > directory, the title and a few options.
    >
    > Doesn't seem to be too onerous.


    The onerous part is keeping track of the library, in
    order to look at the file and see if I NEED to make the
    changes. I'm also I'm a bit mystified as to how I'd
    (cleanly) change the standard task to get the effect I
    want. I'll try explaining again; perhaps you can help.

    I want to be able to have one Rails app generate doc/...
    files, based on the file tree of another app. That is,
    the results should appear locally, but the sources should
    stay (unmodified) over in the other app.

    I don't see six lines (in documentation.rake). Rather, I
    see a long laundry list of "rdoc.rdoc_files.include" calls,
    relative to the current directory. The output files (and
    actions such as rm_rf) are also defined in terms of the
    current directory.

    So, doing a chdir won't help. I could edit the file to
    change the laundry lists, but that seemed onerous to me.
    So, I started looking at redefining "include". How would
    you approach this problem, specifically?

    -r

    P.S. Still having problems with my include aliasing...
    --
    http://www.cfcl.com/rdm Rich Morin
    http://www.cfcl.com/rdm/resume
    http://www.cfcl.com/rdm/weblog +1 650-873-7841

    Technical editing and writing, programming, and web development
     
    Rich Morin, Mar 8, 2007
    #5
  6. Rich Morin

    Rich Morin Guest

    FYI, my current (working) solution looks like this:

    namespace :doc do

    # On occasion, we want to grovel over another app's file tree, but
    # put the results in our own DOC directory. In order to make this
    # happen, we do the following:
    #
    # % setenv README_FOR_APP ...
    # Make sure that $RDOC_SRC_DIR/doc/README_FOR_APP exists.
    # In the following code, do some chdir magic.

    rdoc_src_dir = ENV['RDOC_SRC_DIR']
    if (rdoc_src_dir)
    save_wd = getwd
    chdir(rdoc_src_dir)
    else
    save_wd = '.'
    end
    ...
    rdoc.rdoc_dir = "#{save_wd}/doc/api"
    ...
    --
    http://www.cfcl.com/rdm Rich Morin
    http://www.cfcl.com/rdm/resume
    http://www.cfcl.com/rdm/weblog +1 650-873-7841

    Technical editing and writing, programming, and web development
     
    Rich Morin, Mar 8, 2007
    #6
    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. saurabhnsit2001

    Bit fiddling

    saurabhnsit2001, May 28, 2006, in forum: C Programming
    Replies:
    21
    Views:
    1,769
    Dave Thompson
    Jun 8, 2006
  2. saurabhnsit2001

    Bit fiddling

    saurabhnsit2001, May 28, 2006, in forum: C Programming
    Replies:
    1
    Views:
    347
    Tim Woodall
    May 28, 2006
  3. Bit fiddling calculating fraction

    , Jan 5, 2007, in forum: C Programming
    Replies:
    22
    Views:
    765
    David T. Ashley
    Jan 9, 2007
  4. Joe Van Dyk
    Replies:
    2
    Views:
    115
    Damphyr
    Jan 31, 2006
  5. peppermonkey
    Replies:
    1
    Views:
    264
    Gregory Brown
    Feb 10, 2007
Loading...

Share This Page