summaryrefslogtreecommitdiff
path: root/lib/rdoc/options.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-27 08:54:03 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-27 08:54:03 +0000
commit6d1266a879a94a6f76106e1bbdfa3576b6612a69 (patch)
tree5c88a98d9e588861138e63be7d45353627dcab43 /lib/rdoc/options.rb
parent7de9e2dfdeefeefe6c3d4ff9ebafa8c947eca33f (diff)
* 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
Diffstat (limited to 'lib/rdoc/options.rb')
-rw-r--r--lib/rdoc/options.rb35
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