class YARD::Server::Commands::LibraryCommand
This is the base command for all commands that deal directly with libraries. Some commands do not, but most (like {DisplayObjectCommand}) do. If your command deals with libraries directly, subclass this class instead. See {Base} for notes on how to subclass a command.
@abstract
Attributes
incremental[RW]
@return [Boolean] whether to reparse data
library[RW]
@return [LibraryVersion] the object containing library information
options[RW]
@return [LibraryOptions] default options for the library
serializer[RW]
@return [Serializers::Base] the serializer used to perform file linking
single_library[RW]
@return [Boolean] whether router should route for multiple libraries
Public Class Methods
new(opts = {})
click to toggle source
Calls superclass method
YARD::Server::Commands::Base.new
# File lib/yard/server/commands/library_command.rb, line 51 def initialize(opts = {}) super self.serializer = DocServerSerializer.new end
Public Instance Methods
call(request)
click to toggle source
Calls superclass method
YARD::Server::Commands::Base#call
# File lib/yard/server/commands/library_command.rb, line 56 def call(request) save_default_template_info self.request = request self.options = LibraryOptions.new self.options.reset_defaults self.options.command = self setup_library self.options.title = "Documentation for #{library.name} " + (library.version ? '(' + library.version + ')' : '') super rescue LibraryNotPreparedError not_prepared ensure restore_template_info end
Private Instance Methods
fulldoc_template()
click to toggle source
Hack to load a custom fulldoc template object that does not do any rendering/generation. We need this to access the generate_*_list methods.
# File lib/yard/server/commands/library_command.rb, line 132 def fulldoc_template tplopts = [options.template, :fulldoc, options.format] tplclass = Templates::Engine.template(*tplopts) obj = Object.new.extend(tplclass) class << obj; def init; end end obj.class = tplclass obj.send(:initialize, options) class << obj attr_reader :contents def asset(file, contents) @contents = contents end end obj end
load_yardoc()
click to toggle source
# File lib/yard/server/commands/library_command.rb, line 108 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 Templates::ErbCache.clear! Registry.load_yardoc(library.yardoc_file) Thread.current[:__yard_last_yardoc__] = library.yardoc_file end
not_prepared()
click to toggle source
# File lib/yard/server/commands/library_command.rb, line 120 def not_prepared options.update(:template => :doc_server, :type => :processing) self.caching = false self.status = 202 self.body = render self.headers = {'Content-Type' => 'text/html'} [status, headers, [body]] end
restore_template_info()
click to toggle source
# File lib/yard/server/commands/library_command.rb, line 79 def restore_template_info Templates::Engine.template_paths = @old_template_paths Templates::Template.extra_includes = @old_extra_includes end
save_default_template_info()
click to toggle source
# File lib/yard/server/commands/library_command.rb, line 74 def save_default_template_info @old_template_paths = Templates::Engine.template_paths.dup @old_extra_includes = Templates::Template.extra_includes.dup end
setup_library()
click to toggle source
# File lib/yard/server/commands/library_command.rb, line 84 def setup_library library.prepare! if request.xhr? && request.query['process'] load_yardoc setup_yardopts true end
setup_yardopts()
click to toggle source
# File lib/yard/server/commands/library_command.rb, line 91 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.send(:verify_markup_options) yardoc.options.delete(:serializer) yardoc.options.delete(:serialize) options.update(yardoc.options.to_hash) end end end