Skip to content

Commit dd3f81b

Browse files
committed
Use <dl> for both NOTE and LABEL lists
1 parent 7980bf5 commit dd3f81b

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

lib/rdoc/generator/template/darkfish/rdoc.css

+16-12
Original file line numberDiff line numberDiff line change
@@ -267,27 +267,34 @@ ul.link-list .type {
267267
line-height: 1.4em;
268268
}
269269

270-
.description dl,
271-
#documentation dl {
270+
.note-list {
271+
margin: 8px 0;
272+
}
273+
274+
.label-list {
272275
margin: 8px 1.5em;
273276
border: 1px solid #ccc;
274277
}
275-
.description dl {
278+
.description .label-list {
276279
font-size: 14px;
277280
}
278281

279-
.description dt,
280-
#documentation dt {
282+
.note-list dt {
283+
padding: 2px 0;
284+
font-weight: bold;
285+
}
286+
287+
.label-list dt {
281288
padding: 2px 4px;
282289
font-weight: bold;
283290
background: #ddd;
284291
}
285-
.description dd,
286-
#documentation dd {
292+
.note-list dd,
293+
.label-list dd {
287294
padding: 2px 12px;
288295
}
289-
.description dd + dt,
290-
#documentation dd + dt {
296+
.label-list dd + dt,
297+
.note-list dd + dt {
291298
margin-top: 0.7em;
292299
}
293300

@@ -420,9 +427,6 @@ ul.link-list .type {
420427
cursor: default;
421428
}
422429
#documentation .method-description p {
423-
padding: 0;
424-
}
425-
#documentation .method-description p + p {
426430
margin-bottom: 0.5em;
427431
}
428432
#documentation .method-description ul {

lib/rdoc/markup/to_html.rb

+7-11
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
1313
# Maps RDoc::Markup::Parser::LIST_TOKENS types to HTML tags
1414

1515
LIST_TYPE_TO_HTML = {
16-
:BULLET => ['<ul>', '</ul>'],
17-
:LABEL => ['<dl class="rdoc-list">', '</dl>'],
16+
:BULLET => ['<ul>', '</ul>'],
17+
:LABEL => ['<dl class="rdoc-list label-list">', '</dl>'],
1818
:LALPHA => ['<ol style="display: lower-alpha">', '</ol>'],
19-
:NOTE => ['<table class="rdoc-list">', '</table>'],
20-
:NUMBER => ['<ol>', '</ol>'],
19+
:NOTE => ['<dl class="rdoc-list note-list">', '</dl>'],
20+
:NUMBER => ['<ol>', '</ol>'],
2121
:UALPHA => ['<ol style="display: upper-alpha">', '</ol>'],
2222
}
2323

@@ -340,10 +340,8 @@ def list_item_start(list_item, list_type)
340340
case list_type
341341
when :BULLET, :LALPHA, :NUMBER, :UALPHA then
342342
"<li>"
343-
when :LABEL then
344-
"<dt>#{to_html list_item.label}</dt>\n<dd>"
345-
when :NOTE then
346-
"<tr><td class=\"rdoc-term\"><p>#{to_html list_item.label}</p></td>\n<td>"
343+
when :LABEL, :NOTE then
344+
"<dt>#{to_html list_item.label}\n<dd>"
347345
else
348346
raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
349347
end
@@ -356,10 +354,8 @@ def list_end_for(list_type)
356354
case list_type
357355
when :BULLET, :LALPHA, :NUMBER, :UALPHA then
358356
"</li>"
359-
when :LABEL then
357+
when :LABEL, :NOTE then
360358
"</dd>"
361-
when :NOTE then
362-
"</td></tr>"
363359
else
364360
raise RDoc::Error, "Invalid list type: #{list_type.inspect}"
365361
end

test/test_rdoc_markup_to_html.rb

+10-10
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def accept_list_end_label
7171
assert_equal [], @to.list
7272
assert_equal [], @to.in_list_entry
7373

74-
assert_equal "<dl class=\"rdoc-list\"></dl>\n", @to.res.join
74+
assert_equal "<dl class=\"rdoc-list label-list\"></dl>\n", @to.res.join
7575
end
7676

7777
def accept_list_end_lalpha
@@ -92,7 +92,7 @@ def accept_list_end_note
9292
assert_equal [], @to.list
9393
assert_equal [], @to.in_list_entry
9494

95-
assert_equal "<table class=\"rdoc-list\"></table>\n", @to.res.join
95+
assert_equal "<dl class=\"rdoc-list note-list\"></dl>\n", @to.res.join
9696
end
9797

9898
def accept_list_end_ualpha
@@ -115,7 +115,7 @@ def accept_list_item_end_lalpha
115115
end
116116

117117
def accept_list_item_end_note
118-
assert_equal %w[</td></tr>], @to.in_list_entry
118+
assert_equal %w[</dd>], @to.in_list_entry
119119
end
120120

121121
def accept_list_item_end_number
@@ -131,24 +131,24 @@ def accept_list_item_start_bullet
131131
end
132132

133133
def accept_list_item_start_label
134-
assert_equal "<dl class=\"rdoc-list\"><dt>cat</dt>\n<dd>", @to.res.join
134+
assert_equal "<dl class=\"rdoc-list label-list\"><dt>cat\n<dd>", @to.res.join
135135
end
136136

137137
def accept_list_item_start_lalpha
138138
assert_equal "<ol style=\"display: lower-alpha\"><li>", @to.res.join
139139
end
140140

141141
def accept_list_item_start_note
142-
assert_equal "<table class=\"rdoc-list\"><tr><td class=\"rdoc-term\"><p>cat</p></td>\n<td>",
142+
assert_equal "<dl class=\"rdoc-list note-list\"><dt>cat\n<dd>",
143143
@to.res.join
144144
end
145145

146146
def accept_list_item_start_note_2
147147
expected = <<-EXPECTED
148-
<table class="rdoc-list"><tr><td class="rdoc-term"><p><code>teletype</code></p></td>
149-
<td>
148+
<dl class="rdoc-list note-list"><dt><code>teletype</code>
149+
<dd>
150150
<p>teletype description</p>
151-
</td></tr></table>
151+
</dd></dl>
152152
EXPECTED
153153

154154
assert_equal expected, @to.res.join
@@ -173,7 +173,7 @@ def accept_list_start_label
173173
assert_equal [:LABEL], @to.list
174174
assert_equal [false], @to.in_list_entry
175175

176-
assert_equal '<dl class="rdoc-list">', @to.res.join
176+
assert_equal '<dl class="rdoc-list label-list">', @to.res.join
177177
end
178178

179179
def accept_list_start_lalpha
@@ -187,7 +187,7 @@ def accept_list_start_note
187187
assert_equal [:NOTE], @to.list
188188
assert_equal [false], @to.in_list_entry
189189

190-
assert_equal "<table class=\"rdoc-list\">", @to.res.join
190+
assert_equal "<dl class=\"rdoc-list note-list\">", @to.res.join
191191
end
192192

193193
def accept_list_start_number

0 commit comments

Comments
 (0)