summaryrefslogtreecommitdiffhomepage
path: root/lib/yard
diff options
context:
space:
mode:
authorSeba Gamboa <[email protected]>2015-09-29 12:00:50 -0300
committerSeba Gamboa <[email protected]>2015-09-29 12:00:50 -0300
commit5aaad840a7c59a4c5f2abaead892018c7059b11e (patch)
tree8e6fe7557110e7bf701db363a87ac33cb78eea8e /lib/yard
parentd034793bd327d78aba0d99d719336d597e2413b0 (diff)
downloadyard-mruby-5aaad840a7c59a4c5f2abaead892018c7059b11e.tar.gz
yard-mruby-5aaad840a7c59a4c5f2abaead892018c7059b11e.zip
Refactor return types
Diffstat (limited to 'lib/yard')
-rw-r--r--lib/yard/mruby/code_objects/function_object.rb11
-rw-r--r--lib/yard/mruby/handlers/c/header/function_handler.rb9
2 files changed, 14 insertions, 6 deletions
diff --git a/lib/yard/mruby/code_objects/function_object.rb b/lib/yard/mruby/code_objects/function_object.rb
index ecf7dd5..35b8e4f 100644
--- a/lib/yard/mruby/code_objects/function_object.rb
+++ b/lib/yard/mruby/code_objects/function_object.rb
@@ -22,6 +22,17 @@ module YARD::MRuby::CodeObjects
''
end
+ def return_type
+ obj.tag(:return).types.first
+ end
+
+ def return_type=(type)
+ return if type == 'void'
+ add_tag(YARD::Tags::Tag.new(:return,"", "")) unless has_tag?(:return)
+ tag(:return).types = [type]
+ end
+
+
# Returns all alias names of the object
# @return [Array<Symbol>] the alias names
def aliases
diff --git a/lib/yard/mruby/handlers/c/header/function_handler.rb b/lib/yard/mruby/handlers/c/header/function_handler.rb
index 11f8efc..079f114 100644
--- a/lib/yard/mruby/handlers/c/header/function_handler.rb
+++ b/lib/yard/mruby/handlers/c/header/function_handler.rb
@@ -3,9 +3,9 @@ module YARD::MRuby::Handlers::C::Header
MATCH = /
MRB_(API|INLINE)\s+
((struct\s+)?\w+(\s*\*)?)\s*
- ((\w+\s+)+)?(\w+)\s*\(
+ ((\w+\s+)+)?(\w+)\s*
+ \(([\w\s\*,])*\)
/mx
- #\(([\w\*,]*)\)
handles MATCH
statement_class ToplevelStatement
@@ -25,10 +25,7 @@ module YARD::MRuby::Handlers::C::Header
register_docstring(obj, statement.comments.source, statement)
end
- if retype != 'void'
- obj.add_tag(YARD::Tags::Tag.new(:return,"", "")) unless obj.has_tag?(:return)
- obj.tag(:return).types = [retype]
- end
+ obj.return_type = retype
end
end