Small fixes to the namespace_list template helper
The `namespace_list` helper is used to filter YARD objects in order to populate search lists. The code was originally derived from the `class_list` helper. This patch guards against calling `children` on objects that have no children and removes a recursive call to the old `class_list` method.
This commit is contained in:
parent
0307f0f5e9
commit
32d69848e1
|
@ -34,7 +34,7 @@ def namespace_list(opts = {})
|
||||||
children.reject {|c| c.nil? }.sort_by {|child| child.path }.map do |child|
|
children.reject {|c| c.nil? }.sort_by {|child| child.path }.map do |child|
|
||||||
if namespace_types.include? child.type
|
if namespace_types.include? child.type
|
||||||
name = child.namespace.is_a?(CodeObjects::Proxy) ? child.path : child.name
|
name = child.namespace.is_a?(CodeObjects::Proxy) ? child.path : child.name
|
||||||
has_children = run_verifier(child.children).any? {|o| o.is_a?(CodeObjects::NamespaceObject) }
|
has_children = child.respond_to?(:children) && run_verifier(child.children).any? {|o| o.is_a?(CodeObjects::NamespaceObject) }
|
||||||
out << "<li>"
|
out << "<li>"
|
||||||
out << "<a class='toggle'></a> " if has_children
|
out << "<a class='toggle'></a> " if has_children
|
||||||
out << linkify(child, name)
|
out << linkify(child, name)
|
||||||
|
@ -43,7 +43,7 @@ def namespace_list(opts = {})
|
||||||
out << child.namespace.title
|
out << child.namespace.title
|
||||||
out << "</small>"
|
out << "</small>"
|
||||||
out << "</li>"
|
out << "</li>"
|
||||||
out << "<ul>#{class_list(child)}</ul>" if has_children
|
out << "<ul>#{namespace_list(:root => child, :namespace_types => namespace_types)}</ul>" if has_children
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
out
|
out
|
||||||
|
|
Loading…
Reference in New Issue