class Object
Public Instance Methods
Renders the #box_info section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb, line 9 def box_info @subclasses = Registry.all(:puppet_class).find_all { |c| c.statement.parent_class == object.name.to_s } erb(:box_info) end
Builds the options to PuppetStrings.generate. @param [Hash] options The Puppet face options hash. @param [Array] yard_args The additional arguments to pass to YARD. @return [Hash] Returns the PuppetStrings.generate options hash.
# File lib/puppet/face/strings.rb, line 90 def build_generate_options(options = nil, *yard_args) generate_options = {} generate_options[:debug] = Puppet[:debug] generate_options[:backtrace] = Puppet[:trace] generate_options[:yard_args] = yard_args unless yard_args.empty? if options markup = options[:markup] generate_options[:markup] = markup if markup json_file = options[:emit_json] generate_options[:json] = json_file if json_file generate_options[:json] = nil if options[:emit_json_stdout] end generate_options end
Checks that the required features are installed. @return [void]
# File lib/puppet/face/strings.rb, line 80 def check_required_features raise RuntimeError, "The 'yard' gem must be installed in order to use this face." unless Puppet.features.yard? raise RuntimeError, "The 'rgen' gem must be installed in order to use this face." unless Puppet.features.rgen? raise RuntimeError, 'This face requires Ruby 1.9 or greater.' if RUBY_VERSION =~ /^1\.8/ end
Renders the classes section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 128 def classes @title = 'Puppet Class Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_class) erb(:objects) end
Renders the commands section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb, line 25 def commands @title = 'Commands' @collection = object.commands erb(:collection) end
Renders the confines section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb, line 9 def confines @title = 'Confines' @collection = object.confines erb(:collection) end
Renders the defaults section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb, line 17 def defaults @title = 'Default Provider For' @collection = object.defaults erb(:collection) end
Renders the defined types section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 136 def defined_types @title = 'Defined Type Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_defined_type) erb(:objects) end
Renders the functions section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 160 def functions @title = 'Puppet Function Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_function) erb(:objects) end
Generate a searchable Ruby class list in the output. @return [void]
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 59 def generate_class_list @items = options.objects if options.objects @list_title = 'Ruby Class List' @list_type = 'class' generate_list_contents end
Generates the searchable Ruby method list. @return [void]
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 48 def generate_method_list @items = prune_method_listing(Registry.all(:method), false) @items = @items.reject {|m| m.name.to_s =~ /=$/ && m.is_attribute? } @items = @items.sort_by {|m| m.name.to_s } @list_title = 'Ruby Method List' @list_type = 'method' generate_list_contents end
Generates the searchable Puppet class list. @return [void]
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 3 def generate_puppet_class_list @items = Registry.all(:puppet_class).sort_by { |c| c.name.to_s } @list_title = 'Puppet Class List' @list_type = 'puppet_class' generate_list_contents end
Generates the searchable Puppet defined type list. @return [void]
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 12 def generate_puppet_defined_type_list @items = Registry.all(:puppet_defined_type).sort_by {|dt| dt.name.to_s } @list_title = 'Defined Type List' @list_type = 'puppet_defined_type' generate_list_contents end
Generates the searchable Puppet function list. @return [void]
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 39 def generate_puppet_function_list @items = Registry.all(:puppet_function).sort_by {|f| f.name.to_s } @list_title = 'Puppet Function List' @list_type = 'puppet_function' generate_list_contents end
Generates the searchable Puppet provider list. @return [void]
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 30 def generate_puppet_provider_list @items = Registry.all(:puppet_provider).sort_by {|p| p.name.to_s } @list_title = 'Provider List' @list_type = 'puppet_provider' generate_list_contents end
Generates the searchable Puppet resource type list. @return [void]
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 21 def generate_puppet_type_list @items = Registry.all(:puppet_type).sort_by {|t| t.name.to_s } @list_title = 'Resource Type List' @list_type = 'puppet_type' generate_list_contents end
Initializes the template. @return [void]
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 3 def init case object when '_index.html' @page_title = options.title sections :layout, [:index, [:listing, [:classes, :defined_types, :types, :providers, :functions, :files, :objects]]] else super end end
Renders the layout section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 15 def layout @nav_url = url_for_list(!@file || options.index ? menu_lists.first[:type] : 'file') case object when nil, String @path = nil when @file @path = @file.path when !object.is_a?(YARD::CodeObjects::NamespaceObject) @path = object.parent.path @nav_url = url_for_list('class') when YARD::CodeObjects::ClassObject @path = object.path @nav_url = url_for_list('class') when PuppetStrings::Yard::CodeObjects::Class @nav_url = url_for_list('puppet_class') @page_title = "Puppet Class: #{object.name}" @path = object.path when PuppetStrings::Yard::CodeObjects::DefinedType @nav_url = url_for_list('puppet_defined_type') @page_title = "Defined Type: #{object.name}" @path = object.path when PuppetStrings::Yard::CodeObjects::Type @nav_url = url_for_list('puppet_type') @page_title = "Resource Type: #{object.name}" @path = object.path when PuppetStrings::Yard::CodeObjects::Provider @nav_url = url_for_list('puppet_provider') @page_title = "Provider: #{object.name}" @path = object.path when PuppetStrings::Yard::CodeObjects::Function @nav_url = url_for_list('puppet_function') @page_title = "Puppet Function: #{object.name} (#{object.function_type})" @path = object.path else @path = object.path end erb(:layout) end
Renders the objects section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 168 def objects @title = 'Ruby Namespace Listing A-Z' @objects_by_letter = objects_by_letter(:class, :module) erb(:objects) end
Builds a list of objects by letter. @param [Array] types The types of objects to find. @return [Hash] Returns a hash of first letter of the object name to list of objects.
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 118 def objects_by_letter(*types) hash = {} objects = Registry.all(*types).sort_by {|o| o.name.to_s } objects = run_verifier(objects) objects.each {|o| (hash[o.name.to_s[0,1].upcase] ||= []) << o } hash end
Renders the overload section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/tags/setup.rb, line 13 def overload erb(if object.type == :puppet_function then :puppet_overload else :overload end) end
Called to return parameter tags. @return [Array<YARD::Tag>] Returns the parameter tags if the object should have parameters.
# File lib/puppet-strings/yard/templates/default/tags/setup.rb, line 3 def param tag(:param) if object.type == :method || object.type == :puppet_class || object.type == :puppet_defined_type || object.type == :puppet_function end
Renders the parameters section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb, line 27 def parameters @parameters = object.parameters || [] @parameters.sort_by! { |p| p.name } @tag_title = 'Parameters' erb(:parameters) end
Renders the properties section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb, line 16 def properties # Properties are the same thing as parameters (from the documentation standpoint), # so reuse the same template but with a different title and data source. @parameters = object.properties || [] @parameters.sort_by! { |p| p.name } @tag_title = 'Properties' erb(:parameters) end
Renders the providers section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 152 def providers @title = 'Puppet Provider Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_provider) erb(:objects) end
Renders the types section. @return [String] Returns the rendered section.
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 144 def types @title = 'Resource Type Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_type) erb(:objects) end