lib/yard/code_objects/base.rb in yard-0.6.1 vs lib/yard/code_objects/base.rb in yard-0.6.2

- old
+ new

@@ -398,14 +398,19 @@ # @param [Base, String] other another code object (or object path) # @return [String] the shortest relative path from this object to +other+ # @since 0.5.3 def relative_path(other) - other = other.path if other.respond_to?(:path) + other = Registry.at(other) if String === other && Registry.at(other) + same_parent = false + if other.respond_to?(:path) + same_parent = other.parent == parent + other = other.path + end return other unless namespace common = [path, other].join(" ").match(/^(\S*)\S*(?: \1\S*)*$/)[1] common = path unless common =~ /(\.|::|#)$/ - common = common.sub(/(\.|::|#)[^:#\.]*?$/, '') + common = common.sub(/(\.|::|#)[^:#\.]*?$/, '') if same_parent result = other.sub(/^#{Regexp.quote common}(::|\.|)?/, '') result.empty? ? other : result end # Renders the object using the {Templates::Engine templating system}.