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

This reverts commit 8349a6d9bb.
This commit is contained in:
John Mair 2011-11-05 01:00:15 +13:00
parent f6520da3e1
commit 43f631c49b
2 changed files with 9 additions and 35 deletions

View File

@ -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(/<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 @@ 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

View File

@ -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'}`
# <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
@ -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