# Initializes the template. # @return [void] 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. 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 # Creates the dynamic menu lists. # @return [Array] Returns the dynamic menu list. def create_menu_lists menu_lists = [ { type: 'puppet_class', title: 'Puppet Classes', search_title: 'Puppet Classes' }, { type: 'puppet_defined_type', title: 'Defined Types', search_title: 'Defined Types', }, { type: 'puppet_type', title: 'Resource Types', search_title: 'Resource Types' }, { type: 'puppet_provider', title: 'Providers', search_title: 'Providers' }, { type: 'puppet_function', title: 'Puppet Functions', search_title: 'Puppet Functions' }, { type: 'class', title: 'Ruby Classes', search_title: 'Class List' }, { type: 'method', title: 'Ruby Methods', search_title: 'Method List' }, ] menu_lists.delete_if { |e| YARD::Registry.all(e[:type].intern).empty? } # We must always return at least one group, so always keep the files list menu_lists << { type: 'file', title: 'Files', search_title: 'File List' } if menu_lists.empty? || !YARD::Registry.all(:file).empty? menu_lists end # Gets the menu lists to use. # @return [Array