From b65b75bf2ce955dc8f5fb589732927acc8b72c29 Mon Sep 17 00:00:00 2001 From: drbrain Date: Tue, 11 Dec 2012 07:44:56 +0000 Subject: * lib/rdoc/options.rb: Added --page-dir option for moving pages in doc/ to the top-level. * lib/rdoc/rdoc.rb: ditto. * test/rdoc/test_rdoc_options.rb: Test for the above. * test/rdoc/test_rdoc_rdoc.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rdoc/options.rb | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'lib/rdoc/options.rb') diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb index 57d457a830..7be43ca776 100644 --- a/lib/rdoc/options.rb +++ b/lib/rdoc/options.rb @@ -228,6 +228,12 @@ class RDoc::Options attr_accessor :option_parser + ## + # Directory where guides, FAQ, and other pages not associated with a class + # live. You may leave this unset if these are at the root of your project. + + attr_accessor :page_dir + ## # Is RDoc in pipe mode? @@ -317,6 +323,7 @@ class RDoc::Options @markup = 'rdoc' @coverage_report = false @op_dir = nil + @page_dir = nil @pipe = false @rdoc_include = [] @root = Pathname(Dir.pwd) @@ -468,6 +475,8 @@ class RDoc::Options @exclude = Regexp.new(@exclude.join("|")) end + finish_page_dir + check_files # If no template was specified, use the default template for the output @@ -481,6 +490,20 @@ class RDoc::Options self end + ## + # Fixes the page_dir to be relative to the root_dir and adds the page_dir to + # the files list. + + def finish_page_dir + return unless @page_dir + + @files << @page_dir.to_s + + page_dir = @page_dir.expand_path.relative_path_from @root + + @page_dir = page_dir + end + ## # Returns a properly-space list of generators and their descriptions. @@ -665,7 +688,7 @@ Usage: #{opt.program_name} [options] [names...] opt.separator nil - opt.on("--pipe", + opt.on("--pipe", "-p", "Convert RDoc on stdin to HTML") do @pipe = true end @@ -708,6 +731,18 @@ Usage: #{opt.program_name} [options] [names...] @root = Pathname(root) end + opt.separator nil + + opt.on("--page-dir=DIR", Directory, + "Directory where guides, your FAQ or", + "other pages not associated with a class", + "live. Set this when you don't store", + "such files at your project root.", + "NOTE: Do not use the same file name in", + "the page dir and the root of your project") do |page_dir| + @page_dir = Pathname(page_dir) + end + opt.separator nil opt.separator "Common generator options:" opt.separator nil -- cgit v1.2.3