123456789_123456789_123456789_123456789_123456789_

Class: YARD::Server::Commands::DisplayObjectCommand

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: YARD::Server::Commands::LibraryCommand
Defined in: lib/yard/server/commands/display_object_command.rb

Overview

Displays documentation for a specific object identified by the path

Since:

  • 0.6.0

Class Method Summary

LibraryCommand - Inherited

Base - Inherited

.new

Creates a new command object, setting attributes named by keys in the options hash.

Instance Attribute Summary

Instance Method Summary

::YARD::Server::DocServerHelper - Included

#abs_url, #base_path, #mtime, #mtime_url, #router,
#url_for

Modifies Templates::Helpers::HtmlHelper#url_for to return a URL instead of a disk location.

#url_for_file

Modifies Templates::Helpers::HtmlHelper#url_for_file to return a URL instead of a disk location.

#url_for_frameset

Returns the frames URL for the page.

#url_for_index

Returns the URL for the alphabetic index page.

#url_for_list

Modifies Templates::Helpers::HtmlHelper#url_for_list to return a URL based on the list prefix instead of a HTML filename.

#url_for_main

Returns the main URL, first checking a readme and then linking to the index.

LibraryCommand - Inherited

#call, #call_with_fork, #call_without_fork,
#fulldoc_template

Hack to load a custom fulldoc template object that does not do any rendering/generation.

#load_yardoc, #not_prepared, #restore_template_info, #save_default_template_info, #setup_library, #setup_yardopts

Base - Inherited

#call

The main method called by a router with a request object.

#run

Subclass this method to implement a custom command.

#add_cache_control

Add a conservative cache control policy to reduce load on requests served with "?1234567890" style timestamp query strings.

Constructor Details

This class inherits a constructor from YARD::Server::Commands::LibraryCommand

Instance Method Details

#index

Since:

  • 0.6.0

[ GitHub ]

  
# 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

Since:

  • 0.6.0

[ GitHub ]

  
# File 'lib/yard/server/commands/display_object_command.rb', line 47

def not_found
  super
  self.body = "Could not find object: #{object_path}"
end

#object_path (private)

Since:

  • 0.6.0

[ GitHub ]

  
# 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

#run

Since:

  • 0.6.0

[ GitHub ]

  
# 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