Handle cases where the parser returns nil
The Future Parser will return nil if a manifest file contains no statements (I.E. it is empty or full of comments). Handle these cases and ensure the `enumerate` method of the YARD parser always returns an Array.
This commit is contained in:
parent
afb053c03b
commit
84f31a8074
|
@ -45,5 +45,10 @@ module Puppetx::Yardoc::Pops
|
|||
def transform_Positioned(o)
|
||||
YARDStatement.new(o)
|
||||
end
|
||||
|
||||
# nil in... nil out!
|
||||
def transform_NilClass(o)
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,10 @@ module Puppetx::Yardoc::YARD
|
|||
end
|
||||
|
||||
def enumerator
|
||||
@transformer.transform(@parse_result)
|
||||
statements = @transformer.transform(@parse_result)
|
||||
|
||||
# Ensure an array is returned and prune any nil values.
|
||||
Array(statements).compact
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue