+ # +target+ is a
- def handle_special_HARD_BREAK special
+ def handle_regexp_HARD_BREAK target
'" text = paragraph.text @hard_break text = text.gsub(/\r?\n/, ' ') - @res << wrap(to_html(text)) + @res << to_html(text) @res << "
\n" end @@ -312,7 +312,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter ## # Generate a link to +url+ with content +text+. Handles the special cases - # for img: and link: described under handle_special_HYPERLINK + # for img: and link: described under handle_regexp_HYPERLINK def gen_url url, text scheme, url, id = parse_url url diff --git a/lib/rdoc/markup/to_html_crossref.rb b/lib/rdoc/markup/to_html_crossref.rb index cc93021540..6020263799 100644 --- a/lib/rdoc/markup/to_html_crossref.rb +++ b/lib/rdoc/markup/to_html_crossref.rb @@ -40,7 +40,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml @show_hash = @options.show_hash crossref_re = @hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP - @markup.add_special crossref_re, :CROSSREF + @markup.add_regexp_handling crossref_re, :CROSSREF @cross_reference = RDoc::CrossReference.new @context end @@ -68,8 +68,8 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml # example, ToHtml is found, even without the RDoc::Markup:: prefix, # because we look for it in module Markup first. - def handle_special_CROSSREF(special) - name = special.text + def handle_regexp_CROSSREF(target) + name = target.text return name if name =~ /@[\w-]+\.[\w-]/ # labels that look like emails @@ -87,22 +87,22 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml # Handles rdoc-ref: scheme links and allows RDoc::Markup::ToHtml to # handle other schemes. - def handle_special_HYPERLINK special - return cross_reference $' if special.text =~ /\Ardoc-ref:/ + def handle_regexp_HYPERLINK target + return cross_reference $' if target.text =~ /\Ardoc-ref:/ super end ## - # +special+ is an rdoc-schemed link that will be converted into a hyperlink. + # +target+ is an rdoc-schemed link that will be converted into a hyperlink. # For the rdoc-ref scheme the cross-reference will be looked up and the # given name will be used. # # All other contents are handled by - # {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_special_RDOCLINK] + # {the superclass}[rdoc-ref:RDoc::Markup::ToHtml#handle_regexp_RDOCLINK] - def handle_special_RDOCLINK special - url = special.text + def handle_regexp_RDOCLINK target + url = target.text case url when /\Ardoc-ref:/ then @@ -126,8 +126,6 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml # Creates an HTML link to +name+ with the given +text+. def link name, text - original_name = name - if name =~ /(.*[^#:])@/ then name = $1 label = $' diff --git a/lib/rdoc/markup/to_html_snippet.rb b/lib/rdoc/markup/to_html_snippet.rb index 24aa1d32d9..4eb36592b7 100644 --- a/lib/rdoc/markup/to_html_snippet.rb +++ b/lib/rdoc/markup/to_html_snippet.rb @@ -44,7 +44,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml @mask = 0 @paragraphs = 0 - @markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF + @markup.add_regexp_handling RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF end ## @@ -71,7 +71,7 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml text = paragraph.text @hard_break - @res << "#{para}#{wrap to_html text}\n" + @res << "#{para}#{to_html text}\n" add_paragraph end @@ -123,16 +123,16 @@ class RDoc::Markup::ToHtmlSnippet < RDoc::Markup::ToHtml end ## - # Removes escaping from the cross-references in +special+ + # Removes escaping from the cross-references in +target+ - def handle_special_CROSSREF special - special.text.sub(/\A\\/, '') + def handle_regexp_CROSSREF target + target.text.sub(/\A\\/, '') end ## - # +special+ is a
+ # +target+ is a
- def handle_special_HARD_BREAK special
+ def handle_regexp_HARD_BREAK target
@characters -= 4
'AAA
'
assert_equal 'AAA
', converted
diff --git a/test/rdoc/test_rdoc_markup_to_html.rb b/test/rdoc/test_rdoc_markup_to_html.rb
index 59889dcc5a..c30c89a7e3 100644
--- a/test/rdoc/test_rdoc_markup_to_html.rb
+++ b/test/rdoc/test_rdoc_markup_to_html.rb
@@ -395,7 +395,7 @@ class TestRDocMarkupToHtml < RDoc::Markup::FormatterTestCase
@to.accept_paragraph para("hello\n", "world\n")
- assert_equal "\nhello world
\n", @to.res.join + assert_equal "\nhello world
\n", @to.res.join end def test_accept_heading_output_decoration @@ -727,18 +727,18 @@ EXPECTED assert_equal '', @to.gen_url('https://example.com/image.png', 'ignored') end - def test_handle_special_HYPERLINK_link - special = RDoc::Markup::Special.new 0, 'link:README.txt' + def test_handle_regexp_HYPERLINK_link + target = RDoc::Markup::RegexpHandling.new 0, 'link:README.txt' - link = @to.handle_special_HYPERLINK special + link = @to.handle_regexp_HYPERLINK target assert_equal 'README.txt', link end - def test_handle_special_HYPERLINK_irc - special = RDoc::Markup::Special.new 0, 'irc://irc.freenode.net/#ruby-lang' + def test_handle_regexp_HYPERLINK_irc + target = RDoc::Markup::RegexpHandling.new 0, 'irc://irc.freenode.net/#ruby-lang' - link = @to.handle_special_HYPERLINK special + link = @to.handle_regexp_HYPERLINK target assert_equal 'irc.freenode.net/#ruby-lang', link end diff --git a/test/rdoc/test_rdoc_markup_to_html_crossref.rb b/test/rdoc/test_rdoc_markup_to_html_crossref.rb index 63fc95ff51..19cc6a8ec1 100644 --- a/test/rdoc/test_rdoc_markup_to_html_crossref.rb +++ b/test/rdoc/test_rdoc_markup_to_html_crossref.rb @@ -116,66 +116,66 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase @to.gen_url('http://example', 'HTTP example') end - def test_handle_special_CROSSREF - assert_equal "C2::C3", SPECIAL('C2::C3') + def test_handle_regexp_CROSSREF + assert_equal "C2::C3", REGEXP_HANDLING('C2::C3') end - def test_handle_special_CROSSREF_label + def test_handle_regexp_CROSSREF_label assert_equal "foo at C1#m", - SPECIAL('C1#m@foo') + REGEXP_HANDLING('C1#m@foo') end - def test_handle_special_CROSSREF_show_hash_false + def test_handle_regexp_CROSSREF_show_hash_false @to.show_hash = false assert_equal "m", - SPECIAL('#m') + REGEXP_HANDLING('#m') end - def test_handle_special_HYPERLINK_rdoc + def test_handle_regexp_HYPERLINK_rdoc readme = @store.add_file 'README.txt' readme.parser = RDoc::Parser::Simple @to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2 - link = @to.handle_special_HYPERLINK hyper 'C2::C3' + link = @to.handle_regexp_HYPERLINK hyper 'C2::C3' assert_equal 'C2::C3', link - link = @to.handle_special_HYPERLINK hyper 'C4' + link = @to.handle_regexp_HYPERLINK hyper 'C4' assert_equal 'C4', link - link = @to.handle_special_HYPERLINK hyper 'README.txt' + link = @to.handle_regexp_HYPERLINK hyper 'README.txt' assert_equal 'README.txt', link end - def test_handle_special_TIDYLINK_rdoc + def test_handle_regexp_TIDYLINK_rdoc readme = @store.add_file 'README.txt' readme.parser = RDoc::Parser::Simple @to = RDoc::Markup::ToHtmlCrossref.new @options, 'C2.html', @c2 - link = @to.handle_special_TIDYLINK tidy 'C2::C3' + link = @to.handle_regexp_TIDYLINK tidy 'C2::C3' assert_equal 'tidy', link - link = @to.handle_special_TIDYLINK tidy 'C4' + link = @to.handle_regexp_TIDYLINK tidy 'C4' assert_equal 'tidy', link - link = @to.handle_special_TIDYLINK tidy 'C1#m' + link = @to.handle_regexp_TIDYLINK tidy 'C1#m' assert_equal 'tidy', link - link = @to.handle_special_TIDYLINK tidy 'README.txt' + link = @to.handle_regexp_TIDYLINK tidy 'README.txt' assert_equal 'tidy', link end - def test_handle_special_TIDYLINK_label - link = @to.handle_special_TIDYLINK tidy 'C1#m@foo' + def test_handle_regexp_TIDYLINK_label + link = @to.handle_regexp_TIDYLINK tidy 'C1#m@foo' assert_equal "tidy", link, 'C1#m@foo' @@ -217,20 +217,20 @@ class TestRDocMarkupToHtmlCrossref < XrefTestCase "\n#{text}
\n" end - def SPECIAL text - @to.handle_special_CROSSREF special text + def REGEXP_HANDLING text + @to.handle_regexp_CROSSREF regexp_handling text end def hyper reference - RDoc::Markup::Special.new 0, "rdoc-ref:#{reference}" + RDoc::Markup::RegexpHandling.new 0, "rdoc-ref:#{reference}" end - def special text - RDoc::Markup::Special.new 0, text + def regexp_handling text + RDoc::Markup::RegexpHandling.new 0, text end def tidy reference - RDoc::Markup::Special.new 0, "{tidy}[rdoc-ref:#{reference}]" + RDoc::Markup::RegexpHandling.new 0, "{tidy}[rdoc-ref:#{reference}]" end end diff --git a/test/rdoc/test_rdoc_markup_to_html_snippet.rb b/test/rdoc/test_rdoc_markup_to_html_snippet.rb index 98102ba553..7e01413dda 100644 --- a/test/rdoc/test_rdoc_markup_to_html_snippet.rb +++ b/test/rdoc/test_rdoc_markup_to_html_snippet.rb @@ -458,8 +458,7 @@ So there you have it expected = <<-EXPECTEDHello -
This is some text, it will be cut off after 100 characters -and an ellipsis must follow +
This is some text, it will be cut off after 100 characters and an ellipsis must follow
So there you #{@ellipsis} EXPECTED @@ -563,8 +562,7 @@ NOTE: Given Foo::Bar, Bar is considered a class even though it may be a RDOC expected = <<-EXPECTED -
Extracts the class, selector and method name parts from name
-like Foo::Bar#baz.
+
Extracts the class, selector and method name parts from name
like Foo::Bar#baz.
NOTE: Given Foo::Bar, #{@ellipsis}
EXPECTED
@@ -652,10 +650,10 @@ This routine modifies its +comment+ parameter.
assert_equal 3, @to.characters
end
- def test_handle_special_HYPERLINK_link
- special = RDoc::Markup::Special.new 0, 'link:README.txt'
+ def test_handle_regexp_HYPERLINK_link
+ target = RDoc::Markup::RegexpHandling.new 0, 'link:README.txt'
- link = @to.handle_special_HYPERLINK special
+ link = @to.handle_regexp_HYPERLINK target
assert_equal 'README.txt', link
end
diff --git a/test/rdoc/test_rdoc_parser_ruby.rb b/test/rdoc/test_rdoc_parser_ruby.rb
index 8a3e723614..8188318769 100644
--- a/test/rdoc/test_rdoc_parser_ruby.rb
+++ b/test/rdoc/test_rdoc_parser_ruby.rb
@@ -495,6 +495,43 @@ ruby
assert_equal 'my attr', bar.comment.text
end
+ def test_parse_attr_accessor_with_newline
+ klass = RDoc::NormalClass.new 'Foo'
+ klass.parent = @top_level
+
+ comment = RDoc::Comment.new "##\n# my attr\n", @top_level
+
+ util_parser "attr_accessor :foo, :bar,\n :baz,\n :qux"
+
+ tk = @parser.get_tk
+
+ @parser.parse_attr_accessor klass, RDoc::Parser::Ruby::NORMAL, tk, comment
+
+ assert_equal 4, klass.attributes.length
+
+ foo = klass.attributes[0]
+ assert_equal 'foo', foo.name
+ assert_equal 'RW', foo.rw
+ assert_equal 'my attr', foo.comment.text
+ assert_equal @top_level, foo.file
+ assert_equal 1, foo.line
+
+ bar = klass.attributes[1]
+ assert_equal 'bar', bar.name
+ assert_equal 'RW', bar.rw
+ assert_equal 'my attr', bar.comment.text
+
+ bar = klass.attributes[2]
+ assert_equal 'baz', bar.name
+ assert_equal 'RW', bar.rw
+ assert_equal 'my attr', bar.comment.text
+
+ bar = klass.attributes[3]
+ assert_equal 'qux', bar.name
+ assert_equal 'RW', bar.rw
+ assert_equal 'my attr', bar.comment.text
+ end
+
def test_parse_attr_accessor_nodoc
klass = RDoc::NormalClass.new 'Foo'
klass.parent = @top_level
@@ -2848,6 +2885,35 @@ EXPECTED
assert_equal expected, markup_code
end
+ def test_parse_mutable_heredocbeg
+ @filename = 'file.rb'
+ util_parser <def blah()
+ @str = -<<-EOM
+ EOM
+ end
+EXPECTED
+ expected = expected.rstrip
+
+ @parser.scan
+
+ foo = @top_level.classes.first
+ assert_equal 'Foo', foo.full_name
+
+ blah = foo.method_list.first
+ markup_code = blah.markup_code.sub(/^.*\n/, '')
+ assert_equal expected, markup_code
+ end
+
def test_parse_statements_method_oneliner_with_regexp
util_parser <This is one-hundred characters or more of text in a single paragraph. This
-paragraph will be cut off …
+ This is one-hundred characters or more of text in a single paragraph. This paragraph will be cut off …
EXPECTED
assert_equal expected, snippet(text)