class Object
Public Instance Methods
box_info()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/setup.rb, line 26 def box_info @source_files = [] @methods.each do |method| # extract the file name and line number for each method file_name = method.files[0][0] line_number = method.files[0][1] @source_files.push([method.name, "#{file_name} (#{line_number})"]) end erb(:box_info) end
check_required_features()
click to toggle source
Ensures that the user has the needed features to use puppet strings
# File lib/puppet/face/strings.rb, line 8 def check_required_features unless Puppet.features.yard? raise RuntimeError, "The 'yard' gem must be installed in order to use this face." end unless Puppet.features.rgen? raise RuntimeError, "The 'rgen' gem must be installed in order to use this face." end if RUBY_VERSION.match(/^1\.8/) raise RuntimeError, "This face requires Ruby 1.9 or greater." end end
command_details()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/setup.rb, line 19 def command_details @command_details = object.commands erb(:command_details) end
confine_details()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/setup.rb, line 24 def confine_details @confine_details = object.confines erb(:confine_details) end
default_details()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/setup.rb, line 29 def default_details @default_details = object.defaults erb(:default_details) end
docstring()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/setup.rb, line 44 def docstring @class_details = @template_helper.extract_tag_data(object) erb(:docstring) end
feature_details()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/setup.rb, line 34 def feature_details @feature_details = object.features erb(:feature_details) end
generate_class_list()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/setup.rb, line 1 def generate_class_list @items = options.objects.select{|o| [:module, :class, :root].include? o.type} if options.objects @list_title = "Class List" @list_type = "class" generate_list_contents end
generate_puppet_manifest_list()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/setup.rb, line 8 def generate_puppet_manifest_list @items = options.objects.select{|o| [:hostclass, :definedtype].include? o.type} if options.objects @list_title = "Puppet Manifest List" # This is important. It causes some YARD JavaScript bits to hook in and # perform the correct formatting. @list_class = "class" @list_type = "puppet_manifest" generate_list_contents end
generate_puppet_plugin_list()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/setup.rb, line 18 def generate_puppet_plugin_list # NOTE: PuppetNamaspaceObject might eventually be used for more than just a # container for plugins... @items = options.objects.select{|o| [:puppetnamespace].include? o.type} if options.objects @list_title = "Puppet Plugin List" # This is important. It causes some YARD JavaScript bits to hook in and # perform the correct formatting. @list_class = "class" @list_type = "puppet_plugin" generate_list_contents end
generate_puppet_provider_list()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/setup.rb, line 37 def generate_puppet_provider_list @items = options.objects.select{|o| [:provider].include? o.type} if options.objects @list_title = "Puppet Provider List" @list_type = "puppet_provider" generate_list_contents end
generate_puppet_type_list()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/setup.rb, line 30 def generate_puppet_type_list @items = options.objects.select{|o| [:type].include? o.type} if options.objects @list_title = "Puppet Type List" @list_type = "puppet_type" generate_list_contents end
header()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/setup.rb, line 32 def header if object.type == :hostclass @header_text = "Puppet Class: #{object.name}" elsif object.type == :definedtype @header_text = "Puppet Defined Type: #{object.name}" else @header_text = "#{object.name}" end erb(:header) end
index()
click to toggle source
TODO: This should be extendable. However, the re-assignment of @objects_by_letter prevents that. Submit a pull request.
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/layout/html/setup.rb, line 3 def index @objects_by_letter = {} objects = Registry.all(:class, :module, :type, :puppetnamespace, :hostclass, :definedtype, :provider).sort_by {|o| o.name.to_s } objects = run_verifier(objects) objects.each {|o| (@objects_by_letter[o.name.to_s[0,1].upcase] ||= []) << o } erb(:index) end
init()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/setup.rb, line 6 def init sections :header, :box_info, :pre_docstring, :docstring, :parameter_details @template_helper = TemplateHelper.new @html_helper = HTMLHelper.new @template_helper.check_parameters_match_docs object params = object.parameters.map { |param| param.first } param_tags = object.tags.find_all{ |tag| tag.tag_name == "param"} param_details = @template_helper.extract_param_details(params, param_tags) unless params.nil? @template_helper.check_types_match_docs object, param_details end
method_details_list()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/setup.rb, line 60 def method_details_list @class_details = [] @html_helper = HTMLHelper.new @methods.each do |object| method_info = @template_helper.extract_tag_data(object) param_details = nil param_tags = object.tags.find_all{ |tag| tag.tag_name == "param"} if object['puppet_4x_function'] # Extract the source code source_code = object.source # Extract the parameters for the source code parameters = source_code.match(/(?:def .*)\((.*?)\)/) # Convert the matched string into an array of strings params = parameters.nil? ? nil : parameters[1].split(/\s*,\s*/) param_details = @template_helper.extract_param_details(params, param_tags) unless params.nil? @template_helper.check_types_match_docs object, param_details @template_helper.check_parameters_match_docs object else param_details = @template_helper.comment_only_param_details(param_tags) end method_info[:params] = param_details @class_details.push(method_info) end erb(:method_details_list) end
method_summary()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/setup.rb, line 40 def method_summary @method_details = [] @html_helper = HTMLHelper.new @methods.each do |method| # If there are multiple sentences in the method description, only # use the first one for the summary. If the author did not include # any periods in their summary, include the whole thing first_sentence = method.docstring.match(/^(.*?)\./) brief_summary = first_sentence ? first_sentence : method.docstring return_tag = method.tags.find { |tag| tag.tag_name == "return"} return_types = return_tag.nil? ? nil : return_tag.types @method_details.push({:name => method.name, :short_desc => brief_summary, :return_types => return_types}) end erb(:method_summary) end
namespace_list(opts = {})
click to toggle source
A hacked version of class_list that can be instructed to only display certain namespace types. This allows us to separate Puppet bits from Ruby bits.
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/setup.rb, line 46 def namespace_list(opts = {}) o = { :root => Registry.root, :namespace_types => [:module, :class] }.merge(opts) root = o[:root] namespace_types = o[:namespace_types] out = "" children = run_verifier(root.children) if root == Registry.root children += @items.select {|o| o.namespace.is_a?(CodeObjects::Proxy) } end children.reject {|c| c.nil? }.sort_by {|child| child.path }.map do |child| if namespace_types.include? child.type if child.namespace.is_a?(CodeObjects::Proxy) name = child.path elsif child.is_a?(PuppetX::PuppetLabs::Strings::YARD::CodeObjects::TypeObject) || child.is_a?(PuppetX::PuppetLabs::Strings::YARD::CodeObjects::ProviderObject) name = child.header_name else name = child.name end has_children = child.respond_to?(:children) && run_verifier(child.children).any? {|o| o.is_a?(CodeObjects::NamespaceObject) } out << "<li>" out << "<a class='toggle'></a> " if has_children out << linkify(child, name) out << " < #{child.superclass.name}" if child.is_a?(CodeObjects::ClassObject) && child.superclass out << "<small class='search_info'>" out << child.namespace.title out << "</small>" out << "</li>" out << "<ul>#{namespace_list(:root => child, :namespace_types => namespace_types)}</ul>" if has_children end end out end
parameter_details()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/setup.rb, line 19 def parameter_details return if object.parameters.empty? param_tags = object.tags.find_all{ |tag| tag.tag_name == "param"} params = object.parameters @param_details = [] @param_details = @template_helper.extract_param_details(params, param_tags, true) erb(:parameter_details) end
provider_details()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/type/setup.rb, line 19 def provider_details type_name = object.name.to_s @providers = YARD::Registry.all(:provider).select { |t| t.type_name == type_name } erb(:provider_details) end
source()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/setup.rb, line 16 def source return if owner != object.namespace return if Tags::OverloadTag === object return if object.source.nil? erb(:source) end
subclasses()
click to toggle source
# File lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/setup.rb, line 8 def subclasses # The naming is a bit weird because Ruby classes use `globals.subclasses`. unless globals.hostsubclasses globals.hostsubclasses = {} list = run_verifier Registry.all(:hostclass) list.each {|o| (globals.hostsubclasses[o.parent_class.path] ||= []) << o if o.parent_class } end @subclasses = globals.hostsubclasses[object.path] return if @subclasses.nil? || @subclasses.empty? erb(:subclasses) end