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:

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (DocServerSerializer) initialize(command = nil)

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 = nil)
  super(:basepath => '', :extension => '')
end

Instance Attribute Details

- (String) basepath Originally defined in class YARD::Serializers::FileSystemSerializer

The base path to write data to.

Returns:

- (String) extension Originally defined in class YARD::Serializers::FileSystemSerializer

The extension of the filename (defaults to html)

Returns:

  • (String)

    the extension of the file. Empty string for no extension.

- (SymbolHash) options (readonly) Originally defined in class YARD::Serializers::Base

All serializer options are saved so they can be passed to other serializers.

Returns:

Instance Method Details

- (Object) serialized_path(object)

Since:

  • 0.6.0



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

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