diff options
| author | Seba Gamboa <[email protected]> | 2015-09-23 14:24:03 -0300 |
|---|---|---|
| committer | Seba Gamboa <[email protected]> | 2015-09-23 14:24:03 -0300 |
| commit | aed91b0fb2fe3c2cd3a74e2e5bc23c8bd95ef1db (patch) | |
| tree | 880d0eb2d6ec5d949f4a0ae72980687dd9041740 /lib/yard/handlers | |
| parent | 731c5326b47b34364b2a8f69c6d558f52957a562 (diff) | |
| download | yard-mruby-aed91b0fb2fe3c2cd3a74e2e5bc23c8bd95ef1db.tar.gz yard-mruby-aed91b0fb2fe3c2cd3a74e2e5bc23c8bd95ef1db.zip | |
Making specs works
Diffstat (limited to 'lib/yard/handlers')
| -rw-r--r-- | lib/yard/handlers/c.rb | 5 | ||||
| -rw-r--r-- | lib/yard/handlers/c/mruby_base.rb | 12 | ||||
| -rw-r--r-- | lib/yard/handlers/c/mruby_class_handler.rb | 35 | ||||
| -rw-r--r-- | lib/yard/handlers/c/mruby_method_handler.rb | 21 | ||||
| -rw-r--r-- | lib/yard/handlers/c/mruby_module_handler.rb | 34 | ||||
| -rw-r--r-- | lib/yard/handlers/header.rb | 1 | ||||
| -rw-r--r-- | lib/yard/handlers/header/base.rb | 11 | ||||
| -rw-r--r-- | lib/yard/handlers/header/define_handler.rb | 0 | ||||
| -rw-r--r-- | lib/yard/handlers/header/function_handler.rb | 0 | ||||
| -rw-r--r-- | lib/yard/handlers/header/header_handler.rb | 0 |
10 files changed, 119 insertions, 0 deletions
diff --git a/lib/yard/handlers/c.rb b/lib/yard/handlers/c.rb new file mode 100644 index 0000000..61c4943 --- /dev/null +++ b/lib/yard/handlers/c.rb @@ -0,0 +1,5 @@ +require_relative 'c/mruby_base' +require_relative 'c/mruby_class_handler' +# require_relative 'c/mruby_module_handler' +require_relative 'c/mruby_method_handler' + diff --git a/lib/yard/handlers/c/mruby_base.rb b/lib/yard/handlers/c/mruby_base.rb new file mode 100644 index 0000000..83c237a --- /dev/null +++ b/lib/yard/handlers/c/mruby_base.rb @@ -0,0 +1,12 @@ +module YARD::Handlers::C + class MRubyBase < Base + DEFAULT_NAMESPACES = { + 'mrb->object_class' => 'Object' + } + + def namespace_for_variable(var) + return DEFAULT_NAMESPACES[var] if DEFAULT_NAMESPACES[var] + super + end + end +end diff --git a/lib/yard/handlers/c/mruby_class_handler.rb b/lib/yard/handlers/c/mruby_class_handler.rb new file mode 100644 index 0000000..9e3d1f5 --- /dev/null +++ b/lib/yard/handlers/c/mruby_class_handler.rb @@ -0,0 +1,35 @@ +module YARD::Handlers::C + class MRubyClassHandler < MRubyBase + + TOP_LEVEL_CLASS = /([\w]+)\s*=\s*mrb_define_class\s* + \( + \s*\w+\s*, + \s*"(\w+)"\s*, + \s*([\w\->]+)\s* + \) + /mx + + NAMESPACED_CLASS = /([\w]+)\s*=\s*mrb_define_class_under\s* + \( + \s*\w+\s*, + \s*(\w+)\s*, + \s*"(\w+)"\s*, + \s*([\w\->]+)\s* + \) + /mx + + handles TOP_LEVEL_CLASS + handles NAMESPACED_CLASS + + statement_class BodyStatement + + process do + statement.source.scan(TOP_LEVEL_CLASS) do |var_name, class_name, parent| + handle_class(var_name, class_name, parent) + end + statement.source.scan(NAMESPACED_CLASS) do |var_name, in_module, class_name, parent| + handle_class(var_name, class_name, parent, in_module) + end + end + end +end diff --git a/lib/yard/handlers/c/mruby_method_handler.rb b/lib/yard/handlers/c/mruby_method_handler.rb new file mode 100644 index 0000000..01fb345 --- /dev/null +++ b/lib/yard/handlers/c/mruby_method_handler.rb @@ -0,0 +1,21 @@ +module YARD::Handlers::C + class MRubyMethodHandler < MRubyBase + MATCH1 = /mrb_define_method\s* + \( + \s*\w+\s*, + \s*(\w+)\s*, + \s*"(\w+)"\s*, + \s*(\w+)\s*, + /mx + + handles MATCH1 + statement_class BodyStatement + + process do + statement.source.scan(MATCH1) do |var_name, name, func_name| + handle_method(nil, var_name, name, func_name) + end + end + + end +end diff --git a/lib/yard/handlers/c/mruby_module_handler.rb b/lib/yard/handlers/c/mruby_module_handler.rb new file mode 100644 index 0000000..c9243ac --- /dev/null +++ b/lib/yard/handlers/c/mruby_module_handler.rb @@ -0,0 +1,34 @@ +module YARD::MRuby::Handlers::Source + class ModuleHandler < Base + + TOP_LEVEL_MODULE = /\*([\w]+)\s*=\s*mrb_define_module\s* + \( + \s*\w+\s*, + \s*"(\w+)"\s* + \) + /mx + + NAMESPACED_MODULE = /\*([\w]+)\s*=\s*mrb_define_module_under\s* + \( + \s*\w+\s*, + \s*(\w+)\s*, + \s*"(\w+)"\s* + \) + /mx + + handles TOP_LEVEL_MODULE + handles NAMESPACED_MODULE + + statement_class BodyStatement + + process do + statement.source.scan(TOP_LEVEL_MODULE) do |var_name, module_name| + handle_module(var_name, module_name) + end + statement.source.scan(NAMESPACED_MODULE) do |var_name, in_module, module_name| + handle_module(var_name, module_name, in_module) + end + end + end +end + diff --git a/lib/yard/handlers/header.rb b/lib/yard/handlers/header.rb new file mode 100644 index 0000000..bb39563 --- /dev/null +++ b/lib/yard/handlers/header.rb @@ -0,0 +1 @@ + require_relative 'header/base' diff --git a/lib/yard/handlers/header/base.rb b/lib/yard/handlers/header/base.rb new file mode 100644 index 0000000..35859f7 --- /dev/null +++ b/lib/yard/handlers/header/base.rb @@ -0,0 +1,11 @@ +module YARD + module MRuby + module Handlers + module Header + class Base < YARD::Handlers::Base + include YARD::Parser::C + end + end + end + end +end diff --git a/lib/yard/handlers/header/define_handler.rb b/lib/yard/handlers/header/define_handler.rb new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lib/yard/handlers/header/define_handler.rb diff --git a/lib/yard/handlers/header/function_handler.rb b/lib/yard/handlers/header/function_handler.rb new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lib/yard/handlers/header/function_handler.rb diff --git a/lib/yard/handlers/header/header_handler.rb b/lib/yard/handlers/header/header_handler.rb new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/lib/yard/handlers/header/header_handler.rb |
