(PDOC-27) Don't require options for 3x functions
Prior to this commit, the 3x function handler assumed that at least two arguments (the name and one or more additional arguments) were passed into newfunction when creating a 3x function. However that is not actually required, the only argument needed is the name. Update the 3x function handler so that it will not throw and exception if only one argument is given.
This commit is contained in:
parent
d9d5ae6df9
commit
5257ca4bed
|
@ -66,10 +66,15 @@ class PuppetX::PuppetLabs::Strings::YARD::Handlers::Puppet3xFunctionHandler < YA
|
|||
|
||||
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
|
||||
else
|
||||
opts = [[]]
|
||||
end
|
||||
|
||||
[name, Hash[opts]]
|
||||
|
|
|
@ -51,4 +51,13 @@ describe PuppetX::PuppetLabs::Strings::YARD::Handlers::Puppet3xFunctionHandler d
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue