# File lib/yard/templates/helpers/html_helper.rb, line 309
      def url_for(obj, anchor = nil, relative = true)
        link = nil
        return link unless serializer

        if obj.is_a?(CodeObjects::Base) && !obj.is_a?(CodeObjects::NamespaceObject)
          # If the obj is not a namespace obj make it the anchor.
          anchor, obj = obj, obj.namespace
        end

        objpath = serializer.serialized_path(obj)
        return link unless objpath

        if relative
          fromobj = object
          if object.is_a?(CodeObjects::Base) &&
              !object.is_a?(CodeObjects::NamespaceObject)
            fromobj = owner
          end

          from = serializer.serialized_path(fromobj)
          link = File.relative_path(from, objpath)
        else
          link = objpath
        end

        link + (anchor ? '#' + urlencode(anchor_for(anchor)) : '')
      end