Permalink
Browse files

Introducing a simple @scope tag. Common expected values are 'class', …

…'instance', and 'dual'.
  • Loading branch information...
1 parent cd3eaf3 commit 0b76dad0925579431844af02f799c9f850ede98e @pvande committed Apr 18, 2010
Showing with 20 additions and 1 deletion.
  1. +4 −0 lib/yard-perl-plugin.rb
  2. +16 −1 lib/yard/handlers/perl/sub_handler.rb
@@ -47,4 +47,8 @@ module Engine
register_template_path File.join(File.dirname(__FILE__), '..', 'templates')
end
end
+
+ module Tags
+ Library.define_tag "Method Scope", :scope
+ end
end
@@ -2,9 +2,24 @@ class YARD::Handlers::Perl::SubHandler < YARD::Handlers::Perl::Base
handles Sub
process do
- register MethodObject.new($__PACKAGE__ || :root, statement.name) do |m|
+ method = register MethodObject.new($__PACKAGE__ || :root, statement.name) do |m|
m.source = statement.text
m.visibility = statement.visibility
end
+
+ if method.has_tag?(:scope)
+ case (scope = method.tag(:scope).text.downcase)
+ when 'class', 'instance'
+ method.scope = scope
+ when 'self'
+ method.scope = :instance
+ when 'dual', 'receiver', 'invocant', 'class_or_self'
+ class_method = method.dup
+ class_method.scope = :class
+ register class_method
+ else
+ log.warn "Unrecognized @scope '#{scope}' for method #{statement.name}"
+ end
+ end
end
end

0 comments on commit 0b76dad

Please sign in to comment.