Permalink
Browse files

Revert "Fix @example parsing, parse @note and parse @see."

This reverts commit 8349a6d.
  • Loading branch information...
1 parent f6520da commit 43f631c49b796a787a5e8b6cc625fbf5d2de1b4e @banister banister committed Nov 4, 2011
Showing with 9 additions and 35 deletions.
  1. +7 −9 lib/pry/helpers/command_helpers.rb
  2. +2 −26 test/test_default_commands/test_documentation.rb
View
16 lib/pry/helpers/command_helpers.rb
@@ -122,15 +122,12 @@ def read_between_the_lines(file_name, start_line, end_line)
def process_rdoc(comment, code_type)
comment = comment.dup
- comment.gsub(/!\{/, "{"). # Fix any (Ya)rdoc URI escapes that are found in the comments.
- gsub(/<code>(?:\s*\n)?(.*?)\s*<\/code>/m) { |code| code.gsub(/`/, '___TICK___')}. # Prevent tick double hightlights.
- gsub(/<code>(?:\s*\n)?(.*?)\s*<\/code>/m) { Pry.color ? CodeRay.scan($1, code_type).term : $1 }.
+ comment.gsub(/<code>(?:\s*\n)?(.*?)\s*<\/code>/m) { Pry.color ? CodeRay.scan($1, code_type).term : $1 }.
gsub(/<em>(?:\s*\n)?(.*?)\s*<\/em>/m) { Pry.color ? "\e[1m#{$1}\e[0m": $1 }.
gsub(/<i>(?:\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 @@ def process_yardoc_tag(comment, tag)
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
View
28 test/test_default_commands/test_documentation.rb
@@ -16,38 +16,15 @@
o = Object.new
- # This is a test comment
- # This is a test comment
- # The Test method `{'one': 'value'}`
- # <code>{'two': 'value'}</code>
- # <code>`{'three': 'value'}`</code>
- # @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
end
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 @@ def o.initialize; end
end
end
end
-

0 comments on commit 43f631c

Please sign in to comment.