class YARD::Handlers::Processor

@see Handlers::Base
across different files, look at {#globals}.
processing of a file from {#extra_state}. If you need to access state
properties that any handler can set during the duration of the post
where objects are being created from. You can also access extra stateful
In addition, the {#namespace} can be set during parsing to control
“protected” and “private” statements to be handled in classes and modules.
statements will have access to this state. This allows “public”,
For example, if the {#visibility} is set in a handler, all following
This class is passed to each handler and keeps overall processing state.
{Handlers::Base} objects that are registered to handle the statement.
Iterates over all statements in a file and delegates them to the

def find_handlers(statement)

Returns:
  • (Array) - a list of handlers to process the statement with.

Parameters:
  • statement () -- the statement object to match.
def find_handlers(statement)
  Base.subclasses.find_all do |handler|
    handler_base_class > handler &&
      (handler.namespace_only? ? owner.is_a?(CodeObjects::NamespaceObject) : true) &&
      handles?(handler, statement)
  end
end

def handler_base_class

Returns:
  • (Base) - the base class
def handler_base_class
  handler_base_namespace.const_get(:Base)
end

def handler_base_namespace

Returns:
  • (Module) - the module containing the handlers depending on
def handler_base_namespace
  self.class.namespace_for_handler[parser_type]
end

def handles?(handler, statement)

def handles?(handler, statement)
  return false unless handler.matches_file?(file)
  if handler.method(:handles?).arity == 1
    handler.handles?(statement)
  elsif [-1, 2].include?(handler.method(:handles?).arity)
    handler.handles?(statement, self)
  end
end

def initialize(parser)

Parameters:
  • parser (Parser::SourceParser) -- the parser used to initialize the processor
def initialize(parser)
  @file = parser.file || "(stdin)"
  @namespace = YARD::Registry.root
  @visibility = :public
  @scope = :instance
  @owner = @namespace
  @parser_type = parser.parser_type
  @handlers_loaded = {}
  @globals = parser.globals || OpenStruct.new
  @extra_state = OpenStruct.new
  load_handlers
end

def load_handlers

Returns:
  • (void) -
def load_handlers
  return if @handlers_loaded[parser_type]
  handler_base_namespace.constants.each do |c|
    const = handler_base_namespace.const_get(c)
    unless Handlers::Base.subclasses.include?(const)
      Handlers::Base.subclasses << const
    end
  end
  @handlers_loaded[parser_type] = true
end

def namespace_for_handler; @@parser_type_extensions ||= {} end

def namespace_for_handler; @@parser_type_extensions ||= {} end

def parse_remaining_files

Other tags:
    See: Parser::OrderedParser -

Returns:
  • (void) -
def parse_remaining_files
  if globals.ordered_parser
    globals.ordered_parser.parse
    log.debug("Re-processing #{@file}...")
  end
end

def process(statements)

Returns:
  • (void) -

Parameters:
  • statements (Array) -- a list of statements
def process(statements)
  statements.each_with_index do |stmt, _index|
    find_handlers(stmt).each do |handler|
      begin
        handler.new(self, stmt).process
      rescue HandlerAborted
        log.debug "#{handler} cancelled from #{caller.last}"
        log.debug "\tin file '#{file}':#{stmt.line}:\n\n" + stmt.show + "\n"
      rescue NamespaceMissingError => missingerr
        log.warn "The #{missingerr.object.type} #{missingerr.object.path} has not yet been recognized.\n" \
                 "If this class/method is part of your source tree, this will affect your documentation results.\n" \
                 "You can correct this issue by loading the source file for this object before `#{file}'\n"
      rescue Parser::UndocumentableError => undocerr
        log.warn "in #{handler}: Undocumentable #{undocerr.message}\n" \
                 "\tin file '#{file}':#{stmt.line}:\n\n" + stmt.show + "\n"
      rescue => e
        log.error "Unhandled exception in #{handler}:\n" \
                  "  in `#{file}`:#{stmt.line}:\n\n#{stmt.show}\n"
        log.backtrace(e)
      end
    end
  end
end

def register_handler_namespace(type, ns)

Other tags:
    Since: - 0.6.0
def register_handler_namespace(type, ns)
  namespace_for_handler[type] = ns
end