Sha256: e50d7e31cfee3ed3f1137dab1d0c62308250c7be2286afac0b19f34998fce487

Contents?: true

Size: 891 Bytes

Versions: 40

Compression:

Stored size: 891 Bytes

Contents

# frozen_string_literal: true
# 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 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

40 entries across 39 versions & 6 rubygems

Version Path
kinetic_sdk-5.0.25 gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
kinetic_sdk-5.0.24 gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
kinetic_sdk-5.0.23 gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
kinetic_sdk-5.0.22 gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
kinetic_sdk-5.0.21 gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
kinetic_sdk-5.0.20 gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
yard-0.9.26 lib/yard/handlers/ruby/module_function_handler.rb
qiita_org-0.1.35 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
qiita_org-0.1.34 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
qiita_org-0.1.33 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
qiita_org-0.1.32 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
qiita_org-0.1.31 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
qiita_org-0.1.30 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
qiita_org-0.1.29 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
qiita_org-0.1.28 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
qiita_org-0.1.27 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
qiita_org-0.1.26 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
qiita_org-0.1.25 gems/ruby/2.7.0/gems/yard-0.9.25/lib/yard/handlers/ruby/module_function_handler.rb
yard-0.9.25 lib/yard/handlers/ruby/module_function_handler.rb
yard-0.9.24 lib/yard/handlers/ruby/module_function_handler.rb