Skip to content

Commit 291e2b7

Browse files
committed
Fix references to nested label in table_of_contents
Fixes #1000
1 parent da40c3e commit 291e2b7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/rdoc/generator/template/darkfish/table_of_contents.rhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
unless table.empty? then %>
3737
<ul>
3838
<%- table.each do |item| -%>
39-
<li><a href="<%= klass.path %>#<%= item.aref %>"><%= item.plain_html %></a>
39+
<li><a href="<%= klass.path %>#<%= item.label(klass) %>"><%= item.plain_html %></a>
4040
<%- end -%>
4141
</ul>
4242
<%- end -%>

test/rdoc/test_rdoc_generator_darkfish.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ def test_generate
113113
refute_match(/Ignored/, File.binread('index.html'))
114114
summary = File.binread('index.html')[%r[<summary.*Klass\.html.*</summary>.*</details>]m]
115115
assert_match(%r[Klass/Inner\.html".*>Inner<], summary)
116-
klassnav = File.binread('Klass.html')[%r[<div class="nav-section">.*<div id="class-metadata">]m]
116+
117+
klass = File.binread('Klass.html')
118+
klassnav = klass[%r[<div class="nav-section">.*<div id="class-metadata">]m]
117119
assert_match(
118120
%r[<li>\s*<details open>\s*<summary>\s*<a href=\S+>Heading 1</a>\s*</summary>\s*<ul]m,
119121
klassnav
@@ -122,6 +124,14 @@ def test_generate
122124
%r[<li>\s*<a href=\S+>Heading 1.1.1.1</a>\s*</ul>\s*</details>\s*</li>]m,
123125
klassnav
124126
)
127+
128+
assert_match(/<h1 id="class-Klass-label-Heading\+1">Heading 1(?!\.)/,
129+
klass[%r[<section class=\"description\">.*</section>]m])
130+
toc = File.binread('table_of_contents.html')
131+
assert_match(
132+
%r[<a\s+href="Klass\.html#class-Klass-label-Heading\+1">Heading 1</a>]m,
133+
toc[%r[<h2\s+id=\"classes\">.*(?=<h2\b)]m][%r[<a\s+href="Klass\.html".*(?=</li\b)]m]
134+
)
125135
end
126136

127137
def test_generate_page

0 commit comments

Comments
 (0)