diff options
| author | Yusuke Endoh <mame@ruby-lang.org> | 2025-10-07 18:01:02 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-10-07 09:07:22 +0000 |
| commit | c693b0e4771915127c8e097ae2d84dea53c2b339 (patch) | |
| tree | 2007072aef4b066ea2b6dd69dc6533454dc7a9a5 | |
| parent | 71e231847b8728db109f65b673818e14f691c517 (diff) | |
[ruby/error_highlight] Improve English comments and messages
https://github.com/ruby/error_highlight/commit/5f976265ef
| -rw-r--r-- | lib/error_highlight/base.rb | 9 | ||||
| -rw-r--r-- | lib/error_highlight/core_ext.rb | 2 | ||||
| -rw-r--r-- | lib/error_highlight/formatter.rb | 4 | ||||
| -rw-r--r-- | test/error_highlight/test_error_highlight.rb | 14 |
4 files changed, 14 insertions, 15 deletions
diff --git a/lib/error_highlight/base.rb b/lib/error_highlight/base.rb index a4c65c63e6..22e0bf0dc3 100644 --- a/lib/error_highlight/base.rb +++ b/lib/error_highlight/base.rb @@ -1,13 +1,13 @@ require_relative "version" module ErrorHighlight - # Identify the code fragment at that a given exception occurred. + # Identify the code fragment where a given exception occurred. # # Options: # # point_type: :name | :args - # :name (default) points the method/variable name that the exception occurred. - # :args points the arguments of the method call that the exception occurred. + # :name (default) points to the method/variable name where the exception occurred. + # :args points to the arguments of the method call where the exception occurred. # # backtrace_location: Thread::Backtrace::Location # It locates the code fragment of the given backtrace_location. @@ -113,7 +113,7 @@ module ErrorHighlight snippet = @node.script_lines[lineno - 1 .. last_lineno - 1].join("") snippet += "\n" unless snippet.end_with?("\n") - # It require some work to support Unicode (or multibyte) characters. + # It requires some work to support Unicode (or multibyte) characters. # Tentatively, we stop highlighting if the code snippet has non-ascii characters. # See https://github.com/ruby/error_highlight/issues/4 raise NonAscii unless snippet.ascii_only? @@ -504,7 +504,6 @@ module ErrorHighlight def spot_fcall_for_args _mid, nd_args = @node.children if nd_args && nd_args.first_lineno == nd_args.last_lineno - # binary operator fetch_line(nd_args.first_lineno) @beg_column = nd_args.first_column @end_column = nd_args.last_column diff --git a/lib/error_highlight/core_ext.rb b/lib/error_highlight/core_ext.rb index 2fb07f2e65..d4f91e1185 100644 --- a/lib/error_highlight/core_ext.rb +++ b/lib/error_highlight/core_ext.rb @@ -24,7 +24,7 @@ module ErrorHighlight _, _, snippet, highlight = ErrorHighlight.formatter.message_for(spot).lines out += "\n | #{ snippet } #{ highlight }" else - out += "\n (cannot create a snippet of the method definition; use Ruby 3.5 or later)" + out += "\n (cannot highlight method definition; try Ruby 3.5 or later)" end end ret << "\n" + out if out diff --git a/lib/error_highlight/formatter.rb b/lib/error_highlight/formatter.rb index 5180576405..d2fad9e75c 100644 --- a/lib/error_highlight/formatter.rb +++ b/lib/error_highlight/formatter.rb @@ -56,11 +56,11 @@ module ErrorHighlight end def self.terminal_width - # lazy load io/console, so it's not loaded when 'max_snippet_width' is set + # lazy load io/console to avoid loading it when 'max_snippet_width' is manually set require "io/console" $stderr.winsize[1] if $stderr.tty? rescue LoadError, NoMethodError, SystemCallError - # do not truncate when window size is not available + # skip truncation when terminal window size is unavailable end end diff --git a/test/error_highlight/test_error_highlight.rb b/test/error_highlight/test_error_highlight.rb index be3e360733..208dea8ea9 100644 --- a/test/error_highlight/test_error_highlight.rb +++ b/test/error_highlight/test_error_highlight.rb @@ -1468,7 +1468,7 @@ wrong number of arguments (given 1, expected 2) (ArgumentError) MethodDefLocationSupported ? "| def wrong_number_of_arguments_test(x, y) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" : - "(cannot create a snippet of the method definition; use Ruby 3.5 or later)" + "(cannot highlight method definition; try Ruby 3.5 or later)" } END @@ -1494,7 +1494,7 @@ missing keyword: :kw3 (ArgumentError) MethodDefLocationSupported ? "| def keyword_test(kw1:, kw2:, kw3:) ^^^^^^^^^^^^" : - "(cannot create a snippet of the method definition; use Ruby 3.5 or later)" + "(cannot highlight method definition; try Ruby 3.5 or later)" } END @@ -1515,7 +1515,7 @@ unknown keyword: :kw4 (ArgumentError) MethodDefLocationSupported ? "| def keyword_test(kw1:, kw2:, kw3:) ^^^^^^^^^^^^" : - "(cannot create a snippet of the method definition; use Ruby 3.5 or later)" + "(cannot highlight method definition; try Ruby 3.5 or later)" } END @@ -1545,7 +1545,7 @@ wrong number of arguments (given 1, expected 3) (ArgumentError) MethodDefLocationSupported ? "| def wrong_number_of_arguments_test2( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" : - "(cannot create a snippet of the method definition; use Ruby 3.5 or later)" + "(cannot highlight method definition; try Ruby 3.5 or later)" } END @@ -1567,7 +1567,7 @@ wrong number of arguments (given 1, expected 0) (ArgumentError) MethodDefLocationSupported ? "| v = -> {} ^^" : - "(cannot create a snippet of the method definition; use Ruby 3.5 or later)" + "(cannot highlight method definition; try Ruby 3.5 or later)" } END @@ -1589,7 +1589,7 @@ wrong number of arguments (given 1, expected 0) (ArgumentError) MethodDefLocationSupported ? "| v = lambda { } ^" : - "(cannot create a snippet of the method definition; use Ruby 3.5 or later)" + "(cannot highlight method definition; try Ruby 3.5 or later)" } END @@ -1615,7 +1615,7 @@ wrong number of arguments (given 1, expected 2) (ArgumentError) MethodDefLocationSupported ? "| define_method :define_method_test do |x, y| ^^" : - "(cannot create a snippet of the method definition; use Ruby 3.5 or later)" + "(cannot highlight method definition; try Ruby 3.5 or later)" } END |
