Implement inheritance tree for host classes

Documentation pages for host classes now show the full inheritance tree instead
of just the immediate parent.
This commit is contained in:
Charlie Sharpsteen 2014-05-27 18:51:25 -07:00
parent d8bc2f3dce
commit 787fca8ebc
2 changed files with 22 additions and 2 deletions

View File

@ -33,5 +33,20 @@ module Puppetx::Yardoc::YARD::CodeObjects
yield(obj) if block_given?
obj
end
def inheritance_tree
if parent_class.is_a?(HostClassObject)
# Cool. We got a host class. Return self + parent inheritance tree.
[self] + parent_class.inheritance_tree
elsif parent_class.is_a?(YARD::CodeObjects::Proxy)
# We have a reference to a parent that has not been created yet. Just
# return it.
[self, parent_class]
else
# Most likely no parent class. But also possibly an object that we
# shouldn't inherit from. Just return self.
[self]
end
end
end
end

View File

@ -3,8 +3,13 @@
<% if object.parent_class %>
<dt class="r<%=n%>">Inherits:</dt>
<dd class="r<%=n%>">
<span class="inheritName"><%= linkify object.parent_class %></span>
<%# TODO: Add inheritance tree. %>
<span class="inheritName"><%= linkify object.parent_class, object.parent_class.path %></span>
<ul class="fullTree">
<% object.inheritance_tree.reverse.each_with_index do |obj, i| %>
<li class="next"><%= obj == object ? obj.path : linkify(obj, obj.path) %></li>
<% end %>
</ul>
<a href="#" class="inheritanceTree">show all</a>
</dd>
<% n = 2 %>
<% end %>