diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rdoc/options.rb | 37 | ||||
-rw-r--r-- | lib/rdoc/rdoc.rb | 6 |
2 files changed, 42 insertions, 1 deletions
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 @@ -229,6 +229,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? attr_accessor :pipe @@ -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 @@ -482,6 +491,20 @@ class RDoc::Options 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. def generator_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 @@ -709,6 +732,18 @@ Usage: #{opt.program_name} [options] [names...] 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 diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index eabf4fd3f7..76da5b4289 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -349,6 +349,12 @@ option) filename_path = Pathname(filename).expand_path relative_path = filename_path.relative_path_from @options.root + if @options.page_dir and + relative_path.to_s.start_with? @options.page_dir.to_s then + relative_path = + relative_path.relative_path_from @options.page_dir + end + top_level = @store.add_file filename, relative_path.to_s parser = RDoc::Parser.for top_level, filename, content, @options, @stats |