Separate Puppet namespaces from Ruby namespaces
The default YARD template lumps anything that inherits from `NamespaceObject` into the "Classes" list in HTML output. This patch alters the list generation logic so that Namespaces parsed from manifests are listed in a separate "Puppet Manifests" list.
This commit is contained in:
parent
cb45a80928
commit
9d99018952
|
@ -0,0 +1,2 @@
|
||||||
|
<li><%= link_object(Registry.root, Registry.root.title, nil, false) %></li>
|
||||||
|
<%= namespace_list %>
|
|
@ -0,0 +1 @@
|
||||||
|
<%= namespace_list(:namespace_types => [:hostclass, :definedtype]) %>
|
|
@ -0,0 +1,50 @@
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
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
|
||||||
|
name = child.namespace.is_a?(CodeObjects::Proxy) ? child.path : child.name
|
||||||
|
has_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>#{class_list(child)}</ul>" if has_children
|
||||||
|
end
|
||||||
|
end
|
||||||
|
out
|
||||||
|
end
|
|
@ -7,3 +7,9 @@ def index
|
||||||
objects.each {|o| (@objects_by_letter[o.name.to_s[0,1].upcase] ||= []) << o }
|
objects.each {|o| (@objects_by_letter[o.name.to_s[0,1].upcase] ||= []) << o }
|
||||||
erb(:index)
|
erb(:index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def menu_lists
|
||||||
|
[
|
||||||
|
{:type => 'puppet_manifest', :title => 'Puppet Manifests', :search_title => "Puppet Manifest List"}
|
||||||
|
] + super
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue