Sha256: 2e265e728505f5da558a39c9d70625ccc29cd496df63bdb7bc8dce212e68df42

Contents?: true

Size: 871 Bytes

Versions: 76

Compression:

Stored size: 871 Bytes

Contents

# Handles module_function calls to turn methods into public class methods.
# Also creates a private instance copy of the method.
class YARD::Handlers::Ruby::ModuleFunctionHandler < YARD::Handlers::Ruby::Base
  handles method_call(:module_function)
  namespace_only

  process do
    return if (ident = statement.jump(:ident)) == statement
    case statement.type
    when :var_ref, :vcall
      self.scope = :module
    when :fcall, :command
      statement[1].traverse do |node|
        case node.type
        when :symbol; name = node.first.source
        when :string_content; name = node.source
        else next
        end
        instance_method = MethodObject.new(namespace, name)
        class_method = MethodObject.new(namespace, name, :module)
        instance_method.copy_to(class_method)
        class_method.visibility = :public
      end
    end
  end
end

Version data entries

76 entries across 59 versions & 8 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/yard-0.9.1/lib/yard/handlers/ruby/module_function_handler.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.2/lib/yard/handlers/ruby/module_function_handler.rb
yard-0.9.5 lib/yard/handlers/ruby/module_function_handler.rb
yard-0.9.4 lib/yard/handlers/ruby/module_function_handler.rb
yard-0.9.3 lib/yard/handlers/ruby/module_function_handler.rb
yard-0.9.2 lib/yard/handlers/ruby/module_function_handler.rb
yard-0.9.1 lib/yard/handlers/ruby/module_function_handler.rb
yard-0.9.0 lib/yard/handlers/ruby/module_function_handler.rb
yard-0.8.7.6 lib/yard/handlers/ruby/module_function_handler.rb
yard-0.8.7.5 lib/yard/handlers/ruby/module_function_handler.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/module_function_handler.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/module_function_handler.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/module_function_handler.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/module_function_handler.rb
yard-0.8.7.4 lib/yard/handlers/ruby/module_function_handler.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/module_function_handler.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/module_function_handler.rb
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/module_function_handler.rb
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/module_function_handler.rb
mango-0.7.0 vendor/bundler/ruby/2.0.0/gems/yard-0.8.7.3/lib/yard/handlers/ruby/module_function_handler.rb