class HereDocHelper # NOTE: The following methods duplicate functionality from # Puppet::Util::Reference and Puppet::Parser::Functions.functiondocs # # However, implementing this natively in YARD is a good test for the # feasibility of extracting custom Ruby documentation. In the end, the # existing approach taken by Puppet::Util::Reference may be the best due to # the heavy use of metaprogramming in Types and Providers. # Extracts the Puppet function name and options hash from the parsed # definition. # # @return [(String, Hash{String => String})] def process_parameters(statement) # Passing `false` to prameters excludes the block param from the returned # list. name, opts = statement.parameters(false).compact name = process_element(name) # 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, options] end # Sometimes the YARD parser returns Heredoc strings that start with `<-` # instead of `<<-`. HEREDOC_START = /^