123456789_123456789_123456789_123456789_123456789_

Class: YARD::Server::DocServerSerializer

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: YARD::Serializers::FileSystemSerializer
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

Class Method Summary

::YARD::Serializers::FileSystemSerializer - Inherited

.new

Creates a new FileSystemSerializer with options.

::YARD::Serializers::Base - Inherited

.new

Creates a new serializer with options.

Instance Attribute Summary

::YARD::Serializers::FileSystemSerializer - Inherited

#basepath

The base path to write data to.

#basepath=,
#extension

The extension of the filename (defaults to html).

#extension=

::YARD::Serializers::Base - Inherited

#options

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

Instance Method Summary

::YARD::Serializers::FileSystemSerializer - Inherited

#exists?

Checks the disk for an object and returns whether it was serialized.

#serialize

Serializes object with data to its serialized path (prefixed by the #basepath).

#serialized_path

Implements the serialized path of a code object.

#build_filename_map

Builds a filename mapping from object paths to filesystem path names.

#encode_path_components

Remove special chars from filenames.

#mapped_name

::YARD::Serializers::Base - Inherited

#after_serialize

Called after serialization.

#before_serialize

Called before serialization.

#exists?

Returns whether an object has been serialized.

#serialize

Serializes an object.

#serialized_path

The serialized path of an object.

Constructor Details

.new(_command = nil) ⇒ DocServerSerializer

Since:

  • 0.6.0

[ GitHub ]

  
# File 'lib/yard/server/doc_server_serializer.rb', line 7

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

Instance Method Details

#serialized_path(object)

Since:

  • 0.6.0

[ GitHub ]

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

def serialized_path(object)
  case object
  when CodeObjects::RootObject
    "toplevel"
  when CodeObjects::ExtendedMethodObject
    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

#urlencode(name) (private)

Since:

  • 0.6.0

[ GitHub ]

  
# File 'lib/yard/server/doc_server_serializer.rb', line 31

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