|
1 | 1 | # frozen_string_literal: true
|
2 |
| -## |
3 |
| -# A section of table |
4 | 2 |
|
5 |
| -class RDoc::Markup::Table |
6 |
| - # headers of each column |
7 |
| - attr_accessor :header |
| 3 | +module RDoc |
| 4 | + class Markup |
| 5 | + # A section of table |
| 6 | + class Table < Element |
| 7 | + # Headers of each column |
| 8 | + #: Array[String] |
| 9 | + attr_accessor :header |
8 | 10 |
|
9 |
| - # alignments of each column |
10 |
| - attr_accessor :align |
| 11 | + # Alignments of each column |
| 12 | + #: Array[Symbol?] |
| 13 | + attr_accessor :align |
11 | 14 |
|
12 |
| - # body texts of each column |
13 |
| - attr_accessor :body |
| 15 | + # Body texts of each column |
| 16 | + #: Array[String] |
| 17 | + attr_accessor :body |
14 | 18 |
|
15 |
| - # Creates new instance |
16 |
| - def initialize(header, align, body) |
17 |
| - @header, @align, @body = header, align, body |
18 |
| - end |
19 |
| - |
20 |
| - # :stopdoc: |
21 |
| - def ==(other) |
22 |
| - self.class == other.class and |
23 |
| - @header == other.header and |
24 |
| - @align == other.align and |
25 |
| - @body == other.body |
26 |
| - end |
| 19 | + #: (Array[String], Array[Symbol?], Array[String]) -> void |
| 20 | + def initialize(header, align, body) |
| 21 | + @header, @align, @body = header, align, body |
| 22 | + end |
27 | 23 |
|
28 |
| - def accept(visitor) |
29 |
| - visitor.accept_table @header, @body, @align |
30 |
| - end |
| 24 | + #: (Object) -> bool |
| 25 | + def ==(other) |
| 26 | + self.class == other.class && @header == other.header && |
| 27 | + @align == other.align && @body == other.body |
| 28 | + end |
31 | 29 |
|
32 |
| - def pretty_print(q) |
33 |
| - q.group 2, '[Table: ', ']' do |
34 |
| - q.group 2, '[Head: ', ']' do |
35 |
| - q.seplist @header.zip(@align) do |text, align| |
36 |
| - q.pp text |
37 |
| - if align |
38 |
| - q.text ":" |
39 |
| - q.breakable |
40 |
| - q.text align.to_s |
41 |
| - end |
42 |
| - end |
| 30 | + # @override |
| 31 | + #: (untyped) -> void |
| 32 | + def accept(visitor) |
| 33 | + visitor.accept_table(@header, @body, @align) |
43 | 34 | end
|
44 |
| - q.breakable |
45 |
| - q.group 2, '[Body: ', ']' do |
46 |
| - q.seplist @body do |body| |
47 |
| - q.group 2, '[', ']' do |
48 |
| - q.seplist body do |text| |
| 35 | + |
| 36 | + # @override |
| 37 | + #: (untyped) -> String |
| 38 | + def pretty_print(q) |
| 39 | + q.group 2, '[Table: ', ']' do |
| 40 | + q.group 2, '[Head: ', ']' do |
| 41 | + q.seplist @header.zip(@align) do |text, align| |
49 | 42 | q.pp text
|
| 43 | + if align |
| 44 | + q.text ":" |
| 45 | + q.breakable |
| 46 | + q.text align.to_s |
| 47 | + end |
| 48 | + end |
| 49 | + end |
| 50 | + q.breakable |
| 51 | + q.group 2, '[Body: ', ']' do |
| 52 | + q.seplist @body do |body| |
| 53 | + q.group 2, '[', ']' do |
| 54 | + q.seplist body do |text| |
| 55 | + q.pp text |
| 56 | + end |
| 57 | + end |
50 | 58 | end
|
51 | 59 | end
|
52 | 60 | end
|
|
0 commit comments