Merge pull request #53 from iankronquist/fix-defined-function-crash
(PDOC-45) Puppet 4x functions handle unusual names
This commit is contained in:
commit
eeeb89f565
|
@ -187,6 +187,7 @@ class Puppet4xFunctionHandler < YARD::Handlers::Ruby::Base
|
||||||
|
|
||||||
name = process_element(name)
|
name = process_element(name)
|
||||||
|
|
||||||
|
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -199,12 +200,12 @@ class Puppet4xFunctionHandler < YARD::Handlers::Ruby::Base
|
||||||
# @param ele [YARD::Parser::Ruby::AstNode]
|
# @param ele [YARD::Parser::Ruby::AstNode]
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def process_element(ele)
|
def process_element(ele)
|
||||||
ele = ele.jump(:ident, :string_content)
|
ele = ele.jump(:ident, :string_content, :tstring_content)
|
||||||
|
|
||||||
case ele.type
|
case ele.type
|
||||||
when :ident
|
when :ident
|
||||||
ele.source
|
ele.source
|
||||||
when :string_content
|
when :string_content, :tstring_content
|
||||||
source = ele.source
|
source = ele.source
|
||||||
if HEREDOC_START.match(source)
|
if HEREDOC_START.match(source)
|
||||||
process_heredoc(source)
|
process_heredoc(source)
|
||||||
|
|
|
@ -173,4 +173,17 @@ describe PuppetX::PuppetLabs::Strings::YARD::Handlers::Puppet4xFunctionHandler d
|
||||||
RUBY
|
RUBY
|
||||||
}.to output("").to_stdout_from_any_process
|
}.to output("").to_stdout_from_any_process
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should parse unusually named functions" do
|
||||||
|
# This should not raise a ParseErrorWithIssue exceptoin
|
||||||
|
parse <<-RUBY
|
||||||
|
Puppet::Functions.create_function :'max' do
|
||||||
|
def max(num_a, num_b)
|
||||||
|
num_a >= num_b ? num_a : num_b
|
||||||
|
end
|
||||||
|
end
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue