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

(PDOC-27) Don't require options for 3x functions #26

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
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ puppetversion = ENV['PUPPET_VERSION']
if puppetversion
gem 'puppet', puppetversion
else
gem 'puppet', '~> 3.6.2'
gem 'puppet'
end

group :test do
gem 'rspec'
gem "rspec", "~> 2.14.0", :require => false
gem 'mocha'
gem 'puppetlabs_spec_helper'
gem 'rspec-html-matchers'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,20 @@ def process_parameters

name = process_element(name)

opts = opts.map do |tuple|
# Jump down into the S-Expression that represents a hashrocket, `=>`,
# and the values on either side of it.
tuple.jump(:assoc).map{|e| process_element(e)}
# Don't try to process options if we don't have any
if !opts.nil?
opts = opts.map do |tuple|
# Jump down into the S-Expression that represents a hashrocket, `=>`,
# and the values on either side of it.
tuple.jump(:assoc).map{|e| process_element(e)}
end

options = Hash[opts]
else
options = {}
end

[name, Hash[opts]]
[name, options]
end

# Sometimes the YARD parser returns Heredoc strings that start with `<-`
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/puppet_x/puppetlabs/strings/pops_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
let(:manifest_default) {"#hello world\nclass foo($bar = 3) { }"}
let(:transformer) {PuppetX::PuppetLabs::Strings::Pops::YARDTransformer.new}

describe "transform method" do
it "should perform the correct transformation with parameter defaults" do
describe "transform method" do
it "should perform the correct transformation with parameter defaults" do
model = parser.parse_string(manifest_default).current.definitions.first
statements = transformer.transform(model)
expect(statements.parameters[0][0].class).to be(PuppetX::PuppetLabs::Strings::Pops::YARDStatement)
end
end

it "should perform the correct transofmration without parameter defaults" do
it "should perform the correct transofmration without parameter defaults" do
model = parser.parse_string(manifest).current.definitions.first
statements = transformer.transform(model)
expect(statements.parameters[0][1].class).to be(NilClass)
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,13 @@ def the_namespace()
expect(the_method).to document_a(:type => :method, :docstring => "")
expect(the_namespace).to document_a(:type => :puppetnamespace)
end

it "should process documentation if only one option is passed to newfunction" do
parse <<-RUBY
newfunction(:the_functiion) do |args|
end
RUBY

expect(the_namespace).to document_a(:type => :puppetnamespace)
end
end