summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rdoc/markup/to_rdoc.rb8
-rw-r--r--test/rdoc/support/text_formatter_test_case.rb17
-rw-r--r--test/rdoc/test_rdoc_markup_to_ansi.rb11
-rw-r--r--test/rdoc/test_rdoc_markup_to_bs.rb11
-rw-r--r--test/rdoc/test_rdoc_markup_to_markdown.rb11
-rw-r--r--test/rdoc/test_rdoc_markup_to_rdoc.rb11
6 files changed, 65 insertions, 4 deletions
diff --git a/lib/rdoc/markup/to_rdoc.rb b/lib/rdoc/markup/to_rdoc.rb
index 88234f5096..90763ccfdb 100644
--- a/lib/rdoc/markup/to_rdoc.rb
+++ b/lib/rdoc/markup/to_rdoc.rb
@@ -249,8 +249,8 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
# Adds +table+ to the output
def accept_table header, body, aligns
- widths = header.zip(body) do |h, b|
- [h.size, b.size].max
+ widths = header.zip(*body).map do |cols|
+ cols.map(&:size).max
end
aligns = aligns.map do |a|
case a
@@ -262,12 +262,12 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
:rjust
end
end
- @res << header.zip(widths, aligns) do |h, w, a|
+ @res << header.zip(widths, aligns).map do |h, w, a|
h.__send__(a, w)
end.join("|").rstrip << "\n"
@res << widths.map {|w| "-" * w }.join("|") << "\n"
body.each do |row|
- @res << row.zip(widths, aligns) do |t, w, a|
+ @res << row.zip(widths, aligns).map do |t, w, a|
t.__send__(a, w)
end.join("|").rstrip << "\n"
end
diff --git a/test/rdoc/support/text_formatter_test_case.rb b/test/rdoc/support/text_formatter_test_case.rb
index e359028a29..9b3d7ed626 100644
--- a/test/rdoc/support/text_formatter_test_case.rb
+++ b/test/rdoc/support/text_formatter_test_case.rb
@@ -100,6 +100,23 @@ class RDoc::Markup::TextFormatterTestCase < RDoc::Markup::FormatterTestCase
end
##
+ # Test case that calls <tt>@to.accept_table</tt>
+
+ def test_accept_table_align
+ header = ['AA', 'BB', 'CCCCC']
+ body = [
+ ['', 'bbb', 'c'],
+ ['aaaa', 'b', ''],
+ ['a', '', 'cc']
+ ]
+ aligns = [nil, :left, :right]
+ @to.start_accepting
+ @to.accept_table header, body, aligns
+
+ accept_table_align
+ end
+
+ ##
# Test case that calls <tt>@to.attributes</tt> with an escaped
# cross-reference. If this test doesn't pass something may be very
# wrong.
diff --git a/test/rdoc/test_rdoc_markup_to_ansi.rb b/test/rdoc/test_rdoc_markup_to_ansi.rb
index 81372c64d2..893040cb44 100644
--- a/test/rdoc/test_rdoc_markup_to_ansi.rb
+++ b/test/rdoc/test_rdoc_markup_to_ansi.rb
@@ -348,6 +348,17 @@ words words words words
assert_equal expected, @to.end_accepting
end
+ def accept_table_align
+ expected = "\e[0m" + <<-EXPECTED
+ AA |BB |CCCCC
+----|---|-----
+ |bbb| c
+aaaa|b |
+ a | | cc
+ EXPECTED
+ assert_equal expected, @to.end_accepting
+ end
+
# functional test
def test_convert_list_note
note_list = <<-NOTE_LIST
diff --git a/test/rdoc/test_rdoc_markup_to_bs.rb b/test/rdoc/test_rdoc_markup_to_bs.rb
index 7ebde481e6..93baa6b59f 100644
--- a/test/rdoc/test_rdoc_markup_to_bs.rb
+++ b/test/rdoc/test_rdoc_markup_to_bs.rb
@@ -349,4 +349,15 @@ words words words words
assert_equal expected, @to.end_accepting
end
+ def accept_table_align
+ expected = <<-EXPECTED
+ AA |BB |CCCCC
+----|---|-----
+ |bbb| c
+aaaa|b |
+ a | | cc
+ EXPECTED
+ assert_equal expected, @to.end_accepting
+ end
+
end
diff --git a/test/rdoc/test_rdoc_markup_to_markdown.rb b/test/rdoc/test_rdoc_markup_to_markdown.rb
index 92ed37bc50..1b24eb8ef0 100644
--- a/test/rdoc/test_rdoc_markup_to_markdown.rb
+++ b/test/rdoc/test_rdoc_markup_to_markdown.rb
@@ -346,6 +346,17 @@ words words words words
assert_equal expected, @to.end_accepting
end
+ def accept_table_align
+ expected = <<-EXPECTED
+ AA |BB |CCCCC
+----|---|-----
+ |bbb| c
+aaaa|b |
+ a | | cc
+ EXPECTED
+ assert_equal expected, @to.end_accepting
+ end
+
def test_convert_RDOCLINK
result = @to.convert 'rdoc-garbage:C'
diff --git a/test/rdoc/test_rdoc_markup_to_rdoc.rb b/test/rdoc/test_rdoc_markup_to_rdoc.rb
index 50f4b6dc8b..c6f1aeae10 100644
--- a/test/rdoc/test_rdoc_markup_to_rdoc.rb
+++ b/test/rdoc/test_rdoc_markup_to_rdoc.rb
@@ -346,6 +346,17 @@ words words words words
assert_equal expected, @to.end_accepting
end
+ def accept_table_align
+ expected = <<-EXPECTED
+ AA |BB |CCCCC
+----|---|-----
+ |bbb| c
+aaaa|b |
+ a | | cc
+ EXPECTED
+ assert_equal expected, @to.end_accepting
+ end
+
# functional test
def test_convert_list_note
note_list = <<-NOTE_LIST