Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add a dry-run mode
  • Loading branch information
tiennou committed Aug 8, 2019
commit b9a1b70fe3ba6788ff7d2f0406d3ae017ea5c583
1 change: 1 addition & 0 deletions bin/cm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ desc 'Generate HTML documentation'
long_desc 'Generate HTML docs from a Docurium config file'
command :doc do |c|
c.flag :for, :desc => "The version to generate", :multiple => true
c.switch [:n, "dry-run"], :desc => "Dry-run"
c.action do |global_options,options,args|
file = args.first
Docurium::CLI.doc(file, options)
Expand Down
16 changes: 12 additions & 4 deletions lib/docurium.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def generate_docs
# There's still some work we need to do serially
tally_sigs!(version, data)
force_utf8(data)
sha = @repo.write(data.to_json, :blob)
sha = @repo.write(data.to_json, :blob) unless dry_run?

print "Generating documentation [#{i}/#{nversions}]\r"

Expand All @@ -188,9 +188,11 @@ def generate_docs
head_data = data
end

output_index.add(:path => "#{version}.json", :oid => sha, :mode => 0100644)
examples.each do |path, id|
output_index.add(:path => path, :oid => id, :mode => 0100644)
unless dry_run?
output_index.add(:path => "#{version}.json", :oid => sha, :mode => 0100644)
examples.each do |path, id|
output_index.add(:path => path, :oid => id, :mode => 0100644)
end
end

if head_data
Expand All @@ -200,6 +202,8 @@ def generate_docs

end

return if dry_run?

# We tally the signatures in the order they finished, which is
# arbitrary due to the concurrency, so we need to sort them once
# they've finished.
Expand Down Expand Up @@ -562,4 +566,8 @@ def write_site(index)
def out(text)
puts text
end

def dry_run?
@cli_options[:dry_run]
end
end