lib/yard/handlers/base.rb in yard-0.8.3 vs lib/yard/handlers/base.rb in yard-0.8.4
- old
+ new
@@ -1,7 +1,13 @@
module YARD
module Handlers
+ # Raise this error when a handler should exit before completing.
+ # The exception will be silenced, allowing the next handler(s) in the
+ # queue to be executed.
+ # @since 0.8.4
+ class HandlerAborted < ::RuntimeError; end
+
# Raised during processing phase when a handler needs to perform
# an operation on an object's namespace but the namespace could
# not be resolved.
class NamespaceMissingError < Parser::UndocumentableError
# The object the error occurred on
@@ -338,10 +344,19 @@
def scope; parser.scope end
def scope=(v); parser.scope=(v) end
def globals; parser.globals end
def extra_state; parser.extra_state end
+ # Aborts a handler by raising {Handlers::HandlerAborted}.
+ # An exception will only be logged in debugging mode for
+ # this kind of handler exit.
+ #
+ # @since 0.8.4
+ def abort!
+ raise Handlers::HandlerAborted
+ end
+
# Executes a given block with specific state values for {#owner},
# {#namespace} and {#scope}.
#
# @param [Proc] block the block to execute with specific state
# @option opts [CodeObjects::NamespaceObject] :namespace (value of #namespace)
@@ -471,11 +486,11 @@
return unless object
Tags::Library.transitive_tags.each do |tag|
next if object.namespace.is_a?(Proxy)
next unless object.namespace.has_tag?(tag)
next if object.has_tag?(tag)
- object.docstring.add_tag(*object.namespace.tags(tag))
+ object.add_tag(*object.namespace.tags(tag))
end
end
# @param [CodeObjects::Base] object the object to register
# @return [void]
@@ -492,10 +507,11 @@
# @param [#visibility=] object the object to register
# @param [Symbol] visibility the visibility to set on the object
# @since 0.8.0
def register_visibility(object, visibility = self.visibility)
return unless object.respond_to?(:visibility=)
+ return if object.is_a?(NamespaceObject)
object.visibility = visibility
end
# Registers the same method information on the module function, if
# the object was defined as a module function.
@@ -576,6 +592,6 @@
def caller_method
raise NotImplementedError
end
end
end
-end
\ No newline at end of file
+end