Sha256: f97db945c89153bba9bee3c55810ecea3a9ca46b764d285acc352cdb7cc3c12b

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

module YARD::MRuby::Handlers
  module C
    module Source
      class Base < YARD::Handlers::C::Base

        DEFAULT_NAMESPACES = {
          # 'mrb->top_self'      => '',
          'object_class'  => 'Object',
          'class_class'   => 'Class',
          'module_class'  => 'Module',
          'proc_class'    => 'Proc',
          'string_class'  => 'String',
          'array_class'   => 'Array',
          'hash_class'    => 'Hash',
          'float_class'   => 'Float',
          'fixnum_class'  => 'Fixnum',
          'true_class'    => 'TrueClass',
          'false_class'   => 'FalseClass',
          'nil_class'     => 'NilClass',
          'symbol_class'  => 'Symbol',
          'kernel_module' => 'Kernel',
          'eException_class' => 'Exception',
          'eStandardError_class' => 'StandardError'
        }

        def namespace_for_variable(var)
          DEFAULT_NAMESPACES[ var[/^\w+->(\w+)$/, 1] ] || super
        end

        def handle_class(var_name, class_name, parent, stmt, in_module = nil)
          object = super(var_name, class_name, parent, in_module)

          if stmt.comments
            register_docstring(object, stmt.comments.source, stmt)
          end

          object
        end

        def handle_module(var_name, module_name, stmt, in_module = nil)
          object = super(var_name, module_name, in_module)

          if stmt.comments
            register_docstring(object, stmt.comments.source, stmt)
          end

          object
        end

      end

    end

    YARD::Handlers::Processor.register_handler_namespace :source, Source
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yard-mruby-0.2.2 lib/yard/mruby/handlers/c/source/base.rb
yard-mruby-0.2.1 lib/yard/mruby/handlers/c/source/base.rb
yard-mruby-0.2.0 lib/yard/mruby/handlers/c/source/base.rb