Skip to content

Commit

Permalink
Handle more more method names in type explainer.
Browse files Browse the repository at this point in the history
Fixes #1077
  • Loading branch information
lsegal committed Apr 24, 2017
1 parent e91d41c commit 0271dab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/yard/tags/types_explainer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ def to_s(_singular = true)

# @private
class Parser
include CodeObjects

TOKENS = {
:collection_start => /</,
:collection_end => />/,
:fixed_collection_start => /\(/,
:fixed_collection_end => /\)/,
:type_name => /#\w+|((::)?\w+)+/,
:type_name => /#{ISEP}#{METHODNAMEMATCH}|#{NAMESPACEMATCH}|\w+/,
:type_next => /[,;]/,
:whitespace => /\s+/,
:hash_collection_start => /\{/,
Expand Down
5 changes: 4 additions & 1 deletion spec/tags/types_explainer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ def parse_fail(types)
"Hash{String => Symbol, Number}" => "a Hash with keys made of (Strings) and values of (Symbols or Numbers)",
"Array<Foo, Bar>, List(String, Symbol, #to_s), {Foo, Bar => Symbol, Number}" => "an Array of (Foos or Bars);
a List containing (a String followed by a Symbol followed by an object that responds to #to_s);
a Hash with keys made of (Foos or Bars) and values of (Symbols or Numbers)"
a Hash with keys made of (Foos or Bars) and values of (Symbols or Numbers)",
"#weird_method?, #<=>, #!=" => "an object that responds to #weird_method?;
an object that responds to #<=>;
an object that responds to #!="
}
expect.each do |input, expected|
explain = YARD::Tags::TypesExplainer.explain(input)
Expand Down

0 comments on commit 0271dab

Please sign in to comment.