lib/yard/handlers/ruby/legacy/base.rb in yard-0.7.5 vs lib/yard/handlers/ruby/legacy/base.rb in yard-0.8.0

- old
+ new

@@ -22,12 +22,10 @@ a_handler == stmt.tokens.first.class end end end - protected - # Parses a statement's block with a set of state values. If the # statement has no block, nothing happens. A description of state # values can be found at {Handlers::Base#push_state} # # @param [Hash] opts State options @@ -39,26 +37,50 @@ blk = Parser::Ruby::Legacy::StatementList.new(statement.block) parser.process(blk) end end end - + def call_params - tokens = statement.tokens[1..-1] - tokval_list(tokens, :attr, :identifier, TkId).map do |value| - value.to_s + if statement.tokens.first.is_a?(TkDEF) + extract_method_details.last.map {|param| param.first } + else + tokens = statement.tokens[1..-1] + tokval_list(tokens, :attr, :identifier, TkId).map do |value| + value.to_s + end end end def caller_method if statement.tokens.first.is_a?(TkIDENTIFIER) statement.tokens.first.text + elsif statement.tokens.first.is_a?(TkDEF) + extract_method_details.first else nil end end private + + # Extracts method information for macro expansion only + # + # @todo This is a duplicate implementation of {MethodHandler}. Refactor. + # @return [Array<String,Array<Array<String>>>] the method name followed by method + # arguments (name and optional value) + def extract_method_details + if statement.tokens.to_s =~ /^def\s+(#{METHODMATCH})(?:(?:\s+|\s*\()(.*)(?:\)\s*$)?)?/m + meth, args = $1, $2 + meth.gsub!(/\s+/,'') + args = tokval_list(Parser::Ruby::Legacy::TokenList.new(args), :all) + args.map! {|a| k, v = *a.split('=', 2); [k.strip, (v ? v.strip : nil)] } if args + if meth =~ /(?:#{NSEPQ}|#{CSEPQ})([^#{NSEP}#{CSEPQ}]+)$/ + meth = $` + end + return meth, args + end + end # The string value of a token. For example, the return value for the symbol :sym # would be :sym. The return value for a string +"foo #{ bar}"+ would be the literal # +"foo #{ bar}"+ without any interpolation. The return value of the identifier # 'test' would be the same value: 'test'. Here is a list of common types and \ No newline at end of file