diff options
author | Soutaro Matsumoto <[email protected]> | 2022-02-08 21:23:13 +0900 |
---|---|---|
committer | git <[email protected]> | 2022-02-09 18:45:05 +0900 |
commit | cbd54cba03d0a0ecae1df590ca78751362fda826 (patch) | |
tree | c0fdfff539aaecc6ffee587e56bc345b28dbbac3 /lib/rdoc/parser | |
parent | 88b1d21dbb64b4a310e589b1ac8b7661ea09500f (diff) |
[ruby/rdoc] Skip parentheses on singleton class declaration
https://github.com/ruby/rdoc/commit/b6c6d4f978
Diffstat (limited to 'lib/rdoc/parser')
-rw-r--r-- | lib/rdoc/parser/ruby.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index e546fe2141..3c5f79632c 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -400,6 +400,29 @@ class RDoc::Parser::Ruby < RDoc::Parser end ## + # Skip opening parentheses and yield the block. + # Skip closing parentheses too when exists. + + def skip_parentheses(&block) + left_tk = peek_tk + + if :on_lparen == left_tk[:kind] + get_tk + + ret = skip_parentheses(&block) + + right_tk = peek_tk + if :on_rparen == right_tk[:kind] + get_tk + end + + ret + else + yield + end + end + + ## # Return a superclass, which can be either a constant of an expression def get_class_specification @@ -833,7 +856,7 @@ class RDoc::Parser::Ruby < RDoc::Parser cls = parse_class_regular container, declaration_context, single, name_t, given_name, comment elsif name_t[:kind] == :on_op && name_t[:text] == '<<' - case name = get_class_specification + case name = skip_parentheses { get_class_specification } when 'self', container.name read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS parse_statements container, SINGLE |