class Object
Public Instance Methods
Source
# File lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb, line 11 def alias_of # 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 = 'Alias of' @alias_of = object.alias_of erb(:alias_of) end
Renders the alias_of
section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb, line 11 def box_info @subclasses = Registry.all(:puppet_class).find_all do |c| c.statement.parent_class == object.name.to_s end erb(:box_info) end
Renders the box_info
section. @return [String] Returns the rendered section.
Source
# File lib/puppet/face/strings.rb, line 153 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 generate_options[:path] = options[:out] if options[:out] generate_options[:stdout] = options[:stdout] if options[:describe] generate_options[:describe] = true generate_options[:describe_types] = options[:describe_types] generate_options[:describe_list] = options[:list] generate_options[:providers] = options[:providers] generate_options[:list_providers] = options[:list_providers] end format = options[:format] if format if format.casecmp('markdown').zero? generate_options[:markdown] = true elsif format.casecmp('json').zero? generate_options[:json] = true else raise "Invalid format #{options[:format]}. Please select 'json' or 'markdown'." end end end generate_options 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.
Source
# File lib/puppet/face/strings.rb, line 144 def check_required_features raise "The 'yard' gem must be installed in order to use this face." unless Puppet.features.yard? raise "The 'rgen' gem must be installed in order to use this face." unless Puppet.features.rgen? end
Checks that the required features are installed. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 163 def classes @title = 'Puppet Class Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_class) erb(:objects) end
Renders the classes section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb, line 27 def commands @title = 'Commands' @collection = object.commands erb(:collection) end
Renders the commands section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb, line 11 def confines @title = 'Confines' @collection = object.confines erb(:collection) end
Renders the confines section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 171 def data_types @title = 'Data Type Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_data_type, :puppet_data_type_alias) erb(:objects) end
Renders the data types section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/puppet_provider/html/setup.rb, line 19 def defaults @title = 'Default Provider For' @collection = object.defaults erb(:collection) end
Renders the defaults section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 179 def defined_types @title = 'Defined Type Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_defined_type) erb(:objects) end
Renders the defined types section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/puppet_task/html/setup.rb, line 13 def description json['description'] end
Source
# File lib/puppet-strings/yard/templates/default/tags/setup.rb, line 18 def enum erb(:enum) end
Renders the enum section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 203 def functions @title = 'Puppet Function Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_function) erb(:objects) end
Renders the functions section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 70 def generate_class_list @items = options.objects if options.objects @list_title = 'Ruby Class List' @list_type = 'class' generate_list_contents end
Generate a searchable Ruby class list in the output. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 59 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 Ruby method list. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 5 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
class list. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 14 def generate_puppet_data_type_list @items = Registry.all(:puppet_data_type, :puppet_data_type_alias).sort_by { |dt| dt.name.to_s } @list_title = 'Data Type List' @list_type = 'puppet_data_type' generate_list_contents end
Generates the searchable Puppet
data type list. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 23 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
defined type list. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 50 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
function list. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 88 def generate_puppet_plan_list @items = Registry.all(:puppet_plan).sort_by { |t| t.name.to_s } @list_title = 'Puppet Plan List' @list_type = 'puppet_plan' generate_list_contents end
Generates the searchable Puppet
Plan list. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 41 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
provider list. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 79 def generate_puppet_task_list @items = Registry.all(:puppet_task).sort_by { |t| t.name.to_s } @list_title = 'Puppet Task List' @list_type = 'puppet_task' generate_list_contents end
Generates the searchable Puppet
Task list. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb, line 32 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
Generates the searchable Puppet
resource type list. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 5 def init case object when '_index.html' @page_title = options.title sections :layout, [:index, [:listing, %i[classes data_types defined_types types providers functions tasks plans files objects]]] else super end end
Initializes the template. @return [void]
Source
# File lib/puppet-strings/yard/templates/default/puppet_task/html/setup.rb, line 9 def json object.statement.json end
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 17 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::DataType, PuppetStrings::Yard::CodeObjects::DataTypeAlias @nav_url = url_for_list('puppet_data_type') @page_title = "Data Type: #{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 when PuppetStrings::Yard::CodeObjects::Task @nav_url = url_for_list('puppet_task') @page_title = "Puppet Task: #{object.name}" @path = object.path when PuppetStrings::Yard::CodeObjects::Plan @nav_url = url_for_list('puppet_plan') @page_title = "Puppet Plan: #{object.name}" @path = object.path else @path = object.path end final_layout = erb(:layout) PuppetStrings::Yard::Util.github_to_yard_links(final_layout) if @file && @file.name == 'README' final_layout end
Renders the layout section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb, line 9 def method_listing sort_listing(object.functions) end
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 227 def objects @title = 'Ruby Namespace Listing A-Z' @objects_by_letter = objects_by_letter(:class, :module) erb(:objects) end
Renders the objects section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 153 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
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.
Source
# File lib/puppet-strings/yard/templates/default/tags/setup.rb, line 12 def overload erb(object.type == :puppet_function ? :puppet_overload : :overload) end
Renders the overload section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/tags/setup.rb, line 5 def param tag(:param) if %i[method puppet_class puppet_data_type puppet_defined_type puppet_function puppet_task puppet_plan].include?(object.type) end
Called to return parameter tags. @return [Array<YARD::Tag>] Returns the parameter tags if the object should have parameters.
Source
# File lib/puppet-strings/yard/templates/default/puppet_task/html/setup.rb, line 19 def parameters @parameters = json['parameters'] || [] @parameters.to_a.sort! @tag_title = 'Parameters' erb(:parameters) end
Renders the parameters section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/tasks/generate.rb, line 30 def parse_format_option(args, options, format) return unless args.has_key? format options[format] = !(args[format] == 'false' || args[format].empty?) return unless options[format] options[:path] = args[format] == 'true' ? nil : args[format] end
rubocop:disable Style/PreferredHashMethods Because of Ruby, true and false from the args are both strings and both true. Here, when the arg is set to false (or empty), set it to real false, else real true. Then, if the arg is set simply to ‘true’, assume default behavior is expected and set the path to nil to elicit that, else set to the path given. @param [Hash] args from the Rake task cli @param [Hash] options to send to the generate function @param [Symbol] possible format option @return nil
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 219 def plans @title = 'Puppet Plan Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_plan) erb(:objects) end
Renders the plans section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb, line 18 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. # # "checks" such as "creates" and "onlyif" are another type of property @parameters = (object.properties || []) + (object.checks || []) @parameters.sort_by!(&:name) @tag_title = 'Properties' erb(:parameters) end
Renders the properties section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 195 def providers @title = 'Puppet Provider Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_provider) erb(:objects) end
Renders the providers section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb, line 13 def sort_listing(list) list.sort_by { |o| [o.scope.to_s, o.name.to_s.downcase] } end
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 211 def tasks @title = 'Puppet Task Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_task) erb(:objects) end
Renders the tasks section. @return [String] Returns the rendered section.
Source
# File lib/puppet-strings/yard/templates/default/layout/html/setup.rb, line 187 def types @title = 'Resource Type Listing A-Z' @objects_by_letter = objects_by_letter(:puppet_type) erb(:objects) end
Renders the types section. @return [String] Returns the rendered section.