# A class containing helper methods to aid the generation of HTML
# given formatted data
class HTMLHelper
# Generates the HTML to format the relevant data about return values
def generate_return_types(types, desc = nil)
result = []
result << "(" << types.join(", ") << ")"
if !desc.nil?
result << "-
"
end
result.join
end
# Generates the HTML to format the relevant data about parameters
def generate_parameters(params)
result = []
params.each do |param|
result << ""
# Parameters which are documented in the comments but not
# present in the code itself are given the strike through
# styling in order to show the reader that they do not actually
# exist
if !param[:exists?]
result << ""
end
result << "#{param[:name]} "
result << ""
if param[:types]
result << "(" << "" << param[:types].join(", ") << "" << ")"
# Don't bother with TBD since 3x functions will never have type info per parameter.
# However if the user does want to list a type for some reason that is still supported,
# we just don't want to suggest that they need to
elsif !param[:puppet_3_func]
result << "(TBD)"
end
result << ""
# This is only relevant for manifests, not puppet functions
# This is due to the fact that the scope of a parameter (as illustrated by
# by it's fully qualified name) is not relevant for the parameters in puppet
# functions, but may be for components of a manifest (i.e. classes)
unless param[:fq_name].nil?
result << " => #{param[:fq_name]}"
end
if param[:desc]
result << "- "
end
if !param[:exists?]
result << ""
end
result << ""
end
result.join
end
end