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

- old
+ new

@@ -400,10 +400,14 @@ # @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) return other unless namespace - other.gsub(/^#{Regexp.quote namespace.path}(::|\.)?/, '') + common = [path, other].join(" ").match(/^(\S*)\S*(?: \1\S*)*$/)[1] + common = path unless common =~ /(\.|::|#)$/ + common = common.sub(/(\.|::|#)[^:#\.]*?$/, '') + result = other.sub(/^#{Regexp.quote common}(::|\.|)?/, '') + result.empty? ? other : result end # Renders the object using the {Templates::Engine templating system}. # # @example Formats a class in plaintext