From 6d1266a879a94a6f76106e1bbdfa3576b6612a69 Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 27 Nov 2012 08:54:03 +0000 Subject: * lib/rdoc/*: Added --root option for building documentation outside the source directory. * test/rdoc/*: ditto * common.mk (rdoc): Added --root to rdoc rule git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/options.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'lib/rdoc/options.rb') diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb index d862b0adf3..57d457a830 100644 --- a/lib/rdoc/options.rb +++ b/lib/rdoc/options.rb @@ -1,4 +1,5 @@ require 'optparse' +require 'pathname' ## # RDoc::Options handles the parsing and storage of options @@ -95,6 +96,7 @@ class RDoc::Options option_parser pipe rdoc_include + root static_path stylesheet_url template @@ -104,6 +106,12 @@ class RDoc::Options write_options ] + ## + # Option validator for OptionParser that matches a directory that exists on + # the filesystem. + + Directory = Object.new + ## # Option validator for OptionParser that matches a file or directory that # exists on the filesystem. @@ -230,6 +238,13 @@ class RDoc::Options attr_accessor :rdoc_include + ## + # Root of the source documentation will be generated for. Set this when + # building documentation outside the source directory. Defaults to the + # current directory. + + attr_accessor :root + ## # Include the '#' at the front of hyperlinked instance method names @@ -304,6 +319,7 @@ class RDoc::Options @op_dir = nil @pipe = false @rdoc_include = [] + @root = Pathname(Dir.pwd) @show_hash = false @static_path = [] @stylesheet_url = nil # TODO remove in RDoc 4 @@ -562,6 +578,14 @@ Usage: #{opt.program_name} [options] [names...] end end + opt.accept Directory do |directory| + directory = File.expand_path directory + + raise OptionParser::InvalidArgument unless File.directory? directory + + directory + end + opt.accept Path do |path| path = File.expand_path path @@ -673,6 +697,17 @@ Usage: #{opt.program_name} [options] [names...] @markup = value end + opt.separator nil + + opt.on("--root=ROOT", Directory, + "Root of the source tree documentation", + "will be generated for. Set this when", + "building documentation outside the", + "source directory. Default is the", + "current directory.") do |root| + @root = Pathname(root) + end + opt.separator nil opt.separator "Common generator options:" opt.separator nil -- cgit v1.2.3