mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
05898c5b90
commit
3651f678a7
Notes:
git
2021-03-16 15:47:54 +09:00
8 changed files with 471 additions and 2 deletions
|
@ -237,6 +237,34 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|||
@res << "\n"
|
||||
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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue