class YARD::Server::Commands::DisplayObjectCommand

Displays documentation for a specific object identified by the path

Public Instance Methods

index() click to toggle source
# File lib/yard/server/commands/display_object_command.rb, line 36
def index
  Registry.load_all

  options.update(
    :object => '_index.html',
    :objects => Registry.all(:module, :class),
    :type => :layout
  )
  render
end
not_found() click to toggle source
Calls superclass method
# File lib/yard/server/commands/display_object_command.rb, line 47
def not_found
  super
  self.body = "Could not find object: #{object_path}"
end
run() click to toggle source
# File lib/yard/server/commands/display_object_command.rb, line 9
def run
  if path.empty?
    if options.readme
      filename = options.readme.filename
      opts = adapter.options.merge(
        :index => true, :library => library,
        :path => filename.sub(%r{^#{library.source_path.to_s}/}, '')
      )
      self.status, self.headers, self.body =
        *DisplayFileCommand.new(opts).call(request)
      cache(body)
      return
    else
      self.path = 'index'
    end
  end
  return index if path == 'index'

  object = Registry.at(object_path)
  if object
    options.update(:type => :layout)
    render(object)
  else
    not_found
  end
end

Private Instance Methods

object_path() click to toggle source
# File lib/yard/server/commands/display_object_command.rb, line 54
def object_path
  return @object_path if @object_path
  if path == "toplevel"
    @object_path = :root
  else
    @object_path = path.sub(':', '#').gsub('/', '::').sub(/^toplevel\b/, '').sub(/\.html$/, '')
  end
end