Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --dry-run option #556

Merged
merged 3 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rdoc/generator/json_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions lib/rdoc/rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 28 additions & 0 deletions test/test_rdoc_rdoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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__
Expand Down