Skip to content

(CONT-228) Remove deprecated emit flags #329

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

Merged
merged 2 commits into from
Oct 21, 2022
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
18 changes: 1 addition & 17 deletions lib/puppet/face/strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
option '--markup FORMAT' do
summary "The markup format to use for docstring text (defaults to 'markdown')."
end
option '--emit-json-stdout' do
summary 'DEPRECATED: Print JSON representation of the documentation to stdout.'
end
option '--emit-json PATH' do
summary 'DEPRECATED: Write JSON representation of the documentation to the given file.'
end

summary 'Generate documentation from files.'
arguments '[[search_pattern] ...]'
Expand Down Expand Up @@ -157,12 +151,6 @@ def build_generate_options(options = nil, *yard_args)
generate_options[:backtrace] = Puppet[:trace]
generate_options[:yard_args] = yard_args unless yard_args.empty?
if options
if options[:emit_json]
warn "WARNING: '--emit-json PATH' is deprecated. Use '--format json --out PATH' instead."
end
if options[:emit_json_stdout]
warn "WARNING: '--emit-json-stdout' is deprecated. Use '--format json' instead."
end
markup = options[:markup]
generate_options[:markup] = markup if markup
generate_options[:path] = options[:out] if options[:out]
Expand All @@ -178,15 +166,11 @@ def build_generate_options(options = nil, *yard_args)
if format
if format.casecmp('markdown').zero?
generate_options[:markdown] = true
elsif format.casecmp('json').zero? || options[:emit_json] || options[:emit_json_stdout]
elsif format.casecmp('json').zero?
generate_options[:json] = true
generate_options[:path] ||= options[:emit_json] if options[:emit_json]
else
raise "Invalid format #{options[:format]}. Please select 'json' or 'markdown'."
end
elsif options[:emit_json] || options[:emit_json_stdout]
generate_options[:json] = true
generate_options[:path] ||= options[:emit_json] if options[:emit_json]
end
end
generate_options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper_acceptance'

describe 'Emitting JSON' do
describe 'Generating JSON' do
let(:test_module_path) do
sut_module_path(%r{Module test})
end
Expand Down Expand Up @@ -50,26 +50,14 @@
}
end

[
{ title: '--format json and STDOUT', cmd_line: '--format json' },
{ title: '--emit-json-stdout', cmd_line: '--emit-json-stdout' },
].each do |testcase|
it "emits JSON to stdout when using #{testcase[:title]}" do
output = run_shell("puppet strings generate #{testcase[:cmd_line]} \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\"").stdout.chomp
expect(JSON.parse(output)).to eq(expected)
end
it 'renders JSON to stdout when using --format json' do
output = run_shell("puppet strings generate --format json \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\"").stdout.chomp
expect(JSON.parse(output)).to eq(expected)
end

[
{ title: '--format json and --out', cmd_line: '--format json --out "TMPFILE"' },
{ title: '--emit-json', cmd_line: '--emit-json "TMPFILE"' },
].each do |testcase|
it "writes JSON to a file when using #{testcase[:title]}" do
tmpfile = File.join(remote_tmp_path, 'json_output.json')
cmd = "puppet strings generate #{testcase[:cmd_line].gsub('TMPFILE', tmpfile)} \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\""
run_shell(cmd)
output = JSON.parse(file(tmpfile).content)
expect(output).to eq(expected)
end
it 'writes JSON to a file when using --format json --out' do
tmpfile = File.join(remote_tmp_path, 'json_output.json')
run_shell("puppet strings generate --format json --out #{tmpfile} \"#{test_module_path}/lib/puppet/parser/functions/function3x.rb\"")
expect(JSON.parse(file(tmpfile).content)).to eq(expected)
end
end