having problems fiddling with rake

R

Rich Morin

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 (e-mail address removed)
http://www.cfcl.com/rdm/weblog +1 650-873-7841

Technical editing and writing, programming, and web development
 
J

Jim Weirich

Rich said:
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
 
R

Rich Morin

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 (e-mail address removed)
http://www.cfcl.com/rdm/weblog +1 650-873-7841

Technical editing and writing, programming, and web development
 
J

Jim Weirich

Rich said:
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
 
R

Rich Morin

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 (e-mail address removed)
http://www.cfcl.com/rdm/weblog +1 650-873-7841

Technical editing and writing, programming, and web development
 
R

Rich Morin

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 (e-mail address removed)
http://www.cfcl.com/rdm/weblog +1 650-873-7841

Technical editing and writing, programming, and web development
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top