I am new to ruby and I am going through Peter C.’s book (Novice to
Professional).
I am stuck on a chapter that deals with “Generating Documentation with
RDoc”.
I am using Ruby 1.9.3 on Mac OS with Eclipse. I am trying to create some
Ruby Documentation for my files.
To try that, I am writing a program called Person.rb in Eclipse and then
I try to create Ruby Documentation from the command line but I get an
error message:
From the Command Line, when I type: rdoc person.rb (or any other file).
The Terminal returns the following error message:
file ‘person.rb’ not found (this message comes up for any ruby files)
I know rdoc is installed, that is already a certainty but then I have no
idea how to solve the problem and surprisingly I have not found any
helpful information on the web so far.
From the Command Line, when I type: rdoc person.rb (or any other file).
The Terminal returns the following error message:
file ‘person.rb’ not found (this message comes up for any ruby files)
I know rdoc is installed, that is already a certainty but then I have no
idea how to solve the problem and surprisingly I have not found any
helpful information on the web so far.
Would anyone have an idea of what I should do?
Case sensitivity of your filesystem? You said the file is “Person.rb”
and then you run “rdoc person.rb”. Try “rdoc Person.rb” instead?
Thank you for the suggestion but no case sensitivity is not a problem.
Well… you’re doing something wrong. Since you haven’t shared your
actual terminal output, I can only guess. It looks like the output
you’re seeing is coming from:
def check_files @files.delete_if do |file|
if File.exist? file then
if File.readable? file then
false
else
warn “file ‘#{file}’ not readable”
true
end
else
warn "file '#{file}' not found"
true
end
end
end
So you’re failing on File.exist? file. Try this in the same place /
way you’re running rdoc:
ruby -e ‘p File.exist? ARGV.shift’ Person.rb
and I bet it outputs false. If you can’t tab complete the file in your
terminal, you’re probably not providing the correct path.
Here is the location of the file I try to open:
/Users/hakimbenbekhti/Documents/workspace/Welcome
project/Beginning/Person.rb
Could you tell me how I should indicate the full path to rdoc? (I mean
what is the syntax?)
rdoc is a simple command line tool, so we’re not talking about syntax.
It is no different than ‘cp’, ‘cat’, etc… You need to specify files
for it to process them. This should work:
% cd ~/Documents/workspace/Welcome\ project
% rdoc Beginning/Person.rb
or:
% cd ~/Documents/workspace/Welcome\ project/Beginning
% rdoc Person.rb
P.S. Ugh. avoid spaces in paths if at all possible.
% cd ~/Documents/workspace/Welcome\ project
% rdoc Beginning/Person.rb
or:
% cd ~/Documents/workspace/Welcome\ project/Beginning
% rdoc Person.rb
P.S. Ugh. avoid spaces in paths if at all possible.
Perfect. It is working!
Last login: Sat Feb 23 10:09:14 on console
unknown-78-ca-39-b7-26-28-2:~ hakimbenbekhti$ cd
~/Documents/workspace/Welcome\ project/Beginning
unknown-78-ca-39-b7-26-28-2:Beginning hakimbenbekhti$ rdoc Person.rb
Parsing sources…
100% [ 1/ 1] Person.rb
Generating Darkfish format into
/Users/hakimbenbekhti/Documents/workspace/Welcome
project/Beginning/doc…