lib/inch/language/ruby/provider/yard/docstring.rb in inch-0.5.0.rc8 vs lib/inch/language/ruby/provider/yard/docstring.rb in inch-0.5.0.rc9

- old
+ new

@@ -57,11 +57,11 @@ def to_s @text end - private + protected def first_line @first_line ||= @text.lines.to_a.first end @@ -101,26 +101,32 @@ # in inline docs. # # @param name [String] the name of the method parameter # @return [Array<Regexp>] def mention_parameter_patterns(name) + expr = parameter_notations(name) + [ + /#{expr}\:\:/, # param1:: + /\`#{expr}\`/, # `param1` + /\+#{expr}\+/, # +param1+ + /\+#{expr}\+\:\:/, # +param1+:: + /<tt>#{expr}<\/tt>/, # <tt>param1</tt> + /<tt>#{expr}<\/tt>\:\:/, # <tt>param1</tt>:: + /^#{expr}\ \-\ / # param1 - + ] + end + + # Returns possible notations for +name+. + # matches "param1" and "param1<String,nil>" + # @return [Regexp] + def parameter_notations(name) escaped_name = Regexp.escape(name) type = /<[^>]+>/ - [ - escaped_name, - /#{escaped_name}#{type}/ # matches "param1<String,nil>" - ].map do |expr| - [ - /#{expr}\:\:/, # param1:: - /\+#{expr}\+/, # +param1+ - /\+#{expr}\+\:\:/, # +param1+:: - /<tt>#{expr}<\/tt>/, # <tt>param1</tt> - /<tt>#{expr}<\/tt>\:\:/, # <tt>param1</tt>:: - /^#{expr}\ \-\ / # param1 - - ] - end.flatten + /(#{escaped_name}|#{escaped_name}#{type})/ end + # Returns regexes to match parameter description on the next + # line. def describe_parameter_extra_regexps(name) [ "#{name}::", "+#{name}+::", "<tt>#{name}</tt>::"