Sha256: 0a72b81d9077dd3b75953b03102b01094d6bdf4d5b946b6ed030995502a2418a

Contents?: true

Size: 1.3 KB

Versions: 15

Compression:

Stored size: 1.3 KB

Contents

require 'webrick/httputils'

module YARD
  module Server
    # A custom {Serializers::Base serializer} which returns resource URLs instead of
    # static relative paths to files on disk.
    class DocServerSerializer < Serializers::FileSystemSerializer
      include WEBrick::HTTPUtils

      def initialize(command = nil)
        super(:basepath => '', :extension => '')
      end

      def serialized_path(object)
        case object
        when CodeObjects::RootObject
          "toplevel"
        when CodeObjects::ExtendedMethodObject
          name = object.name.to_s
          serialized_path(object.namespace) + ':' + urlencode(object.name.to_s)
        when CodeObjects::MethodObject
          serialized_path(object.namespace) +
            (object.scope == :instance ? ":" : ".") + urlencode(object.name.to_s)
        when CodeObjects::ConstantObject, CodeObjects::ClassVariableObject
          serialized_path(object.namespace) + "##{object.name}-#{object.type}"
        when CodeObjects::ExtraFileObject
          super(object).gsub(/^file\./, 'file/')
        else
          super(object)
        end
      end

      private

      def urlencode(name)
        if name.respond_to?(:force_encoding)
          name = name.dup.force_encoding('binary')
        end
        escape(name)
      end
    end
  end
end

Version data entries

15 entries across 14 versions & 3 rubygems

Version Path
yard-0.8.7.6 lib/yard/server/doc_server_serializer.rb
yard-0.8.7.5 lib/yard/server/doc_server_serializer.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/doc_server_serializer.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/lib/yard/server/doc_server_serializer.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/doc_server_serializer.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/doc_server_serializer.rb
yard-0.8.7.4 lib/yard/server/doc_server_serializer.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/doc_server_serializer.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/doc_server_serializer.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/lib/yard/server/doc_server_serializer.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/doc_server_serializer.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/doc_server_serializer.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/doc_server_serializer.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/server/doc_server_serializer.rb
yard-0.8.7.3 lib/yard/server/doc_server_serializer.rb