summaryrefslogtreecommitdiff
path: root/lib/rdoc/markup/to_rdoc.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rdoc/markup/to_rdoc.rb')
-rw-r--r--lib/rdoc/markup/to_rdoc.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/rdoc/markup/to_rdoc.rb b/lib/rdoc/markup/to_rdoc.rb
index 81b16c4973..3cdf4fd08b 100644
--- a/lib/rdoc/markup/to_rdoc.rb
+++ b/lib/rdoc/markup/to_rdoc.rb
@@ -238,6 +238,34 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
end
##
+ # Adds +table+ to the output
+
+ def accept_table header, body, aligns
+ widths = header.zip(body) do |h, b|
+ [h.size, b.size].max
+ end
+ aligns = aligns.map do |a|
+ case a
+ when nil
+ :center
+ when :left
+ :ljust
+ when :right
+ :rjust
+ end
+ end
+ @res << header.zip(widths, aligns) 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|
+ t.__send__(a, w)
+ end.join("|").rstrip << "\n"
+ end
+ end
+
+ ##
# Applies attribute-specific markup to +text+ using RDoc::AttributeManager
def attributes text