Class: YARD::Server::DocServerSerializer

Inherits:
YARD::Serializers::FileSystemSerializer show all
Includes:
WEBrick::HTTPUtils
Defined in:
lib/yard/server/doc_server_serializer.rb

Overview

A custom serializer which returns resource URLs instead of static relative paths to files on disk.

Since:

  • 0.6.0

Instance Attribute Summary

Attributes inherited from YARD::Serializers::FileSystemSerializer

#basepath, #extension

Attributes inherited from YARD::Serializers::Base

#options

Instance Method Summary collapse

Methods inherited from YARD::Serializers::FileSystemSerializer

#exists?, #serialize

Methods inherited from YARD::Serializers::Base

#after_serialize, #before_serialize, #exists?, #serialize

Constructor Details

#initialize(command) ⇒ DocServerSerializer

Returns a new instance of DocServerSerializer

Since:

  • 0.6.0



10
11
12
# File 'lib/yard/server/doc_server_serializer.rb', line 10

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

Instance Method Details

#serialized_path(object) ⇒ Object

Since:

  • 0.6.0



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/yard/server/doc_server_serializer.rb', line 14

def serialized_path(object)
  path = case object
  when CodeObjects::RootObject
    "toplevel"
  when CodeObjects::MethodObject
    return escape_path(serialized_path(object.namespace) + (object.scope == :instance ? ":" : ".") + object.name.to_s)
  when CodeObjects::ConstantObject, CodeObjects::ClassVariableObject
    return escape_path(serialized_path(object.namespace)) + "##{object.name}-#{object.type}"
  else
    object.path.gsub('::', '/')
  end
  command = options[:command]
  library_path = command.single_library ? '' : '/' + command.library.to_s
  return escape_path(File.join('', command.adapter.router.docs_prefix, library_path, path))
end