diff --git a/lib/rdoc/generator/json_index.rb b/lib/rdoc/generator/json_index.rb index ea9384e6d3..c63a0e591c 100644 --- a/lib/rdoc/generator/json_index.rb +++ b/lib/rdoc/generator/json_index.rb @@ -161,7 +161,7 @@ def generate # Compress the search_index.js file using gzip def generate_gzipped - return unless defined?(Zlib) + return if @options.dry_run or not defined?(Zlib) debug_msg "Compressing generated JSON index" out_dir = @base_dir + @options.op_dir diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index adcb65b13b..e0e28ddf97 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -521,13 +521,18 @@ def document options # by the RDoc options def generate - Dir.chdir @options.op_dir do - unless @options.quiet then - $stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..." - end - + if @options.dry_run then + # do nothing @generator.generate - update_output_dir '.', @start_time, @last_modified + else + Dir.chdir @options.op_dir do + unless @options.quiet then + $stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..." + end + + @generator.generate + update_output_dir '.', @start_time, @last_modified + end end end diff --git a/test/test_rdoc_rdoc.rb b/test/test_rdoc_rdoc.rb index be7a90c236..d5ce1639e4 100644 --- a/test/test_rdoc_rdoc.rb +++ b/test/test_rdoc_rdoc.rb @@ -40,6 +40,34 @@ def test_document # functional test assert_equal 'title', store.title end + def test_document_with_dry_run # functional test + options = RDoc::Options.new + options.files = [File.expand_path('../xref_data.rb', __FILE__)] + options.setup_generator 'darkfish' + options.main_page = 'MAIN_PAGE.rdoc' + options.root = Pathname File.expand_path('..', __FILE__) + options.title = 'title' + options.dry_run = true + + rdoc = RDoc::RDoc.new + + out = nil + temp_dir do + out, = capture_io do + rdoc.document options + end + + refute File.directory? 'doc' + assert_equal rdoc, rdoc.store.rdoc + end + assert_includes out, '100%' + + store = rdoc.store + + assert_equal 'MAIN_PAGE.rdoc', store.main + assert_equal 'title', store.title + end + def test_gather_files a = File.expand_path __FILE__ b = File.expand_path '../test_rdoc_text.rb', __FILE__