List subclasses for each host class
Basically a straight port of the logic from the YARD template for Ruby classes.
This commit is contained in:
parent
787fca8ebc
commit
d226d08ddb
|
@ -1,5 +1 @@
|
||||||
include T('default/module/html')
|
include T('default/module/html')
|
||||||
|
|
||||||
def init
|
|
||||||
sections :header, :box_info, :pre_docstring, T('docstring'), :children
|
|
||||||
end
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<div id="subclasses">
|
||||||
|
<h2>Direct Known Subclasses</h2>
|
||||||
|
<p class="children"><%= @subclasses.map {|child| linkify(child, child.path) }.join(", ") %></p>
|
||||||
|
</div>
|
|
@ -0,0 +1,19 @@
|
||||||
|
include T('default/module')
|
||||||
|
|
||||||
|
def init
|
||||||
|
sections :header, :box_info, :pre_docstring, T('docstring'), :subclasses
|
||||||
|
end
|
||||||
|
|
||||||
|
def subclasses
|
||||||
|
# The naming is a bit weird because Ruby classes use `globals.subclasses`.
|
||||||
|
unless globals.hostsubclasses
|
||||||
|
globals.hostsubclasses = {}
|
||||||
|
list = run_verifier Registry.all(:hostclass)
|
||||||
|
list.each {|o| (globals.hostsubclasses[o.parent_class.path] ||= []) << o if o.parent_class }
|
||||||
|
end
|
||||||
|
|
||||||
|
@subclasses = globals.hostsubclasses[object.path]
|
||||||
|
|
||||||
|
return if @subclasses.nil? || @subclasses.empty?
|
||||||
|
erb(:subclasses)
|
||||||
|
end
|
Loading…
Reference in New Issue