From 43f631c49b796a787a5e8b6cc625fbf5d2de1b4e Mon Sep 17 00:00:00 2001 From: John Mair Date: Sat, 5 Nov 2011 01:00:15 +1300 Subject: [PATCH] Revert "Fix @example parsing, parse @note and parse @see." This reverts commit 8349a6d9bbd9f33739e05c0ad1edc8468015b983. --- lib/pry/helpers/command_helpers.rb | 16 +++++------ .../test_documentation.rb | 28 ++----------------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/lib/pry/helpers/command_helpers.rb b/lib/pry/helpers/command_helpers.rb index 19a97793..82e3d155 100644 --- a/lib/pry/helpers/command_helpers.rb +++ b/lib/pry/helpers/command_helpers.rb @@ -122,15 +122,12 @@ class Pry def process_rdoc(comment, code_type) comment = comment.dup - comment.gsub(/!\{/, "{"). # Fix any (Ya)rdoc URI escapes that are found in the comments. - gsub(/(?:\s*\n)?(.*?)\s*<\/code>/m) { |code| code.gsub(/`/, '___TICK___')}. # Prevent tick double hightlights. - gsub(/(?:\s*\n)?(.*?)\s*<\/code>/m) { Pry.color ? CodeRay.scan($1, code_type).term : $1 }. + comment.gsub(/(?:\s*\n)?(.*?)\s*<\/code>/m) { Pry.color ? CodeRay.scan($1, code_type).term : $1 }. gsub(/(?:\s*\n)?(.*?)\s*<\/em>/m) { Pry.color ? "\e[1m#{$1}\e[0m": $1 }. gsub(/(?:\s*\n)?(.*?)\s*<\/i>/m) { Pry.color ? "\e[1m#{$1}\e[0m" : $1 }. - gsub(/@example(((\n\s{2,})?[^\n]+)+)/) { |code| code.gsub(/`/, '___TICK___') }. # Prevent tick doube highlights. - gsub(/@example(((\n\s{2,})?[^\n]+)+)/) { Pry.color ? "\e[33mexample\e[0m" + CodeRay.scan($1, code_type).term : "example#{$1}" }. - gsub(/`([^`]+)`/) { Pry.color ? CodeRay.scan($1, code_type).term : $1 }. - gsub(/___TICK___/, Pry.color ? "\e[33m`\e[0m" : '`') + gsub(/\B\+(\w*?)\+\B/) { Pry.color ? "\e[32m#{$1}\e[0m": $1 }. + gsub(/((?:^[ \t]+.+(?:\n+|\Z))+)/) { Pry.color ? CodeRay.scan($1, code_type).term : $1 }. + gsub(/`(?:\s*\n)?(.*?)\s*`/) { Pry.color ? CodeRay.scan($1, code_type).term : $1 } end def process_yardoc_tag(comment, tag) @@ -149,8 +146,9 @@ class Pry end def process_yardoc(comment) - yard_tags = ["param", "return", "option", "yield", "attr", "attr_reader", "attr_writer", "deprecate", "note", "see"] - (yard_tags).inject(comment) { |a, v| process_yardoc_tag(a, v) }. + yard_tags = ["param", "return", "option", "yield", "attr", "attr_reader", "attr_writer", + "deprecate", "example"] + (yard_tags - ["example"]).inject(comment) { |a, v| process_yardoc_tag(a, v) }. gsub(/^@(#{yard_tags.join("|")})/) { Pry.color ? "\e[33m#{$1}\e[0m": $1 } end diff --git a/test/test_default_commands/test_documentation.rb b/test/test_default_commands/test_documentation.rb index 36d93e3f..80a1ca12 100644 --- a/test/test_default_commands/test_documentation.rb +++ b/test/test_default_commands/test_documentation.rb @@ -16,20 +16,7 @@ describe "Pry::DefaultCommands::Documentation" do o = Object.new - # This is a test comment - # This is a test comment - # The Test method `{'one': 'value'}` - # {'two': 'value'} - # `{'three': 'value'}` - # @note A message - # @example `{'four': 'value'}` - # @example {'five': 'value'} - # @example - # `{'six': 'value'}` - # @example - # {'seven': 'value'} - # {'eight': 'value'} - # @see https://github.com/pry/pry + # sample comment def o.sample redirect_pry_io(InputTester.new("show-doc", "exit-all"), $str_output) do binding.pry @@ -37,17 +24,7 @@ describe "Pry::DefaultCommands::Documentation" do end o.sample - $str_output.string.should =~ /This is a test comment/ - $str_output.string.should =~ / This is a test comment/ - $str_output.string.should =~ /The Test method \{'one': 'value'\}/ - $str_output.string.should =~ /\{'two': 'value'\}/ - $str_output.string.should =~ /`\{'three': 'value'\}`/ - $str_output.string.should =~ /note A message/ - $str_output.string.should =~ /example `\{'four': 'value'\}`/ - $str_output.string.should =~ /example \{'five': 'value'\}/ - $str_output.string.should =~ /example\n `\{'six': 'value'\}`/ - $str_output.string.should =~ /example\n \{'seven': 'value'\}\n \{'eight': 'value'\}/ - $str_output.string.should =~ /see https:\/\/github.com\/pry\/pry/ + $str_output.string.should =~ /sample comment/ $str_output = nil end @@ -75,4 +52,3 @@ describe "Pry::DefaultCommands::Documentation" do end end end -