diff options
Diffstat (limited to 'lib/rdoc/options.rb')
-rw-r--r-- | lib/rdoc/options.rb | 35 |
1 files changed, 35 insertions, 0 deletions
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 @@ -105,6 +107,12 @@ class RDoc::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. @@ -231,6 +239,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 attr_accessor :show_hash @@ -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 @@ -674,6 +698,17 @@ Usage: #{opt.program_name} [options] [names...] 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 |