Here is my one, reproduced in full. It’s written for a specific
project (extensions.rubyforge.org), but could perhaps be generalised.
It actually uses a shell script to run RDoc, but that could be
implemented here instead.
The target directory for documentation in the code below is
/usr/doc/ruby, or /usr/local/doc/ruby, or C:/Ruby/doc/ruby, etc; it’s
derived from “prefix”.
Cheers,
Gavin
···
On Saturday, January 17, 2004, 7:31:14 AM, Sam wrote:
I can’t find it now (in under a minute), but somebody posted an
equivalent to the standard install.rb (install-doc.rb?) that would run
rdoc on the .rb files, and install the docs in a “standard” location.
If you search the RAA or ruby-talk archives, hopefully you can find it.
I thought i bookmarked it, but its lost at the moment.
Cheers,
Sam
install-doc.rb
Quick ‘n’ dirty script to generate and install the documentation. It uses
(prefix), which would be /usr or /usr/local on a Unix system, and something
like C:/ruby on a Windows system, and adds “doc/ruby” to make a guess at a
documentation directory.
It then creates or reuses the directory “extensions-m.n”, where m.n is the
version number as contained in VERSION.
In order to generate the documentation in the first place, it runs
“sh etc/gen-rdoc.sh”. This is Unix-specific; suggestions to overcome
this are welcome. Personally, I use Cygwin on Windows. This command
generates documentation in the “doc” directory, from where it is copied.
The above assumptions mean that this program must be run from the root
directory of the “exstensions” project.
require “fileutils”
require “rbconfig”
$LOGGING = true
module Kernel
def log(msg = “”)
puts “LOG: #{msg}” if $LOGGING
end
end
1. Determine the target directory.
include Config
prefix = CONFIG[‘prefix’]
rubydocdir = File.join(prefix, “doc”, “ruby”)
log “Default ruby doc dir is #{rubydocdir}”
target_base = ARGV.shift
if target_base.nil?
log “No target directory given; using default”
target_base = rubydocdir
else
log “Using target directory given on command line: #{target_base}”
end
unless File.directory?(target_base)
log “#{target_base} does not exist. Can’t continue.”
exit!
end
version = File.read(“VERSION”).strip
log “Version: #{version}”
target_dir = File.join(target_base, “extensions-#{version}”)
log “Target directory: #{target_dir}”
unless File.directory?(target_dir)
FileUtils.mkdir(target_dir)
log “Created target directory: #{target_dir}”
end
target_rdoc_dir = File.join(target_dir, “rdoc”)
unless File.directory?(target_rdoc_dir)
FileUtils.mkdir(target_rdoc_dir)
log “Created target rdoc directory: #{target_rdoc_dir}”
end
2. Generate the documentation.
command = %w{sh -c etc/gen-rdoc.sh}
log “Command: #{command.join(’ ')}”
unless system(*command)
log “Command failed; exiting.”
exit!
end
3. Clean out the target directory.
Not really needed?
Dir.chdir(target_rdoc_dir) do
FileUtils.rm_rf(“.”)
end
4. Copy the documentation to the target directory.
FileUtils.cp_r(“rdoc”, target_rdoc_dir, :verbose => true)
FileUtils.cp(“README.1st”, target_dir, :verbose => true)
FileUtils.cp(“HISTORY”, target_dir, :verbose => true)
FileUtils.cp(“ChangeLog”, target_dir, :verbose => true)
5. Finished.
log “Done.”