class YARD::Server::Commands::LibraryCommand

@abstract
See {Base} for notes on how to subclass a command.
command deals with libraries directly, subclass this class instead.
Some commands do not, but most (like {DisplayObjectCommand}) do. If your
This is the base command for all commands that deal directly with libraries.

def call(request)

def call(request)
  self.request = request
  self.options = SymbolHash.new(false).update(
    :serialize => false,
    :serializer => serializer,
    :library => library,
    :adapter => adapter,
    :single_library => single_library,
    :markup => :rdoc,
    :format => :html
  )
  setup_library
  super
rescue LibraryNotPreparedError
  not_prepared
end

def initialize(opts = {})

def initialize(opts = {})
  super
  self.serializer = DocServerSerializer.new(self)
end

def load_yardoc

def load_yardoc
  raise LibraryNotPreparedError unless library.yardoc_file
  if Thread.current[:__yard_last_yardoc__] == library.yardoc_file
    log.debug "Reusing yardoc file: #{library.yardoc_file}"
    return
  end
  Registry.clear
  Registry.load_yardoc(library.yardoc_file)
  Thread.current[:__yard_last_yardoc__] = library.yardoc_file
end

def not_prepared

def not_prepared
  self.caching = false
  options.update(:path => request.path, :template => :doc_server, :type => :processing)
  [302, {'Content-Type' => 'text/html'}, [render]]
end

def setup_library

def setup_library
  library.prepare! if request.xhr? && request.query['process']
  load_yardoc
  setup_yardopts
  true
end

def setup_yardopts

def setup_yardopts
  @@library_chdir_lock.synchronize do
    Dir.chdir(library.source_path) do
      yardoc = CLI::Yardoc.new
      if incremental
        yardoc.run('-c', '-n', '--no-stats')
      else
        yardoc.parse_arguments
      end
      yardoc.options.delete(:serializer)
      yardoc.options[:files].unshift(*Dir.glob('README*'))
      options.update(yardoc.options.to_hash)
    end
  end
end