Skip to content

Commit

Permalink
[ruby/rdoc] Fix references to nested label in table_of_contents
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu authored and matzbot committed May 2, 2023
1 parent 83a822f commit 3833d0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -36,7 +36,7 @@
unless table.empty? then %>
<ul>
<%- table.each do |item| -%>
<li><a href="<%= klass.path %>#<%= item.aref %>"><%= item.plain_html %></a>
<li><a href="<%= klass.path %>#<%= item.label(klass) %>"><%= item.plain_html %></a>
<%- end -%>
</ul>
<%- end -%>
Expand Down
12 changes: 11 additions & 1 deletion test/rdoc/test_rdoc_generator_darkfish.rb
Expand Up @@ -113,7 +113,9 @@ def test_generate
refute_match(/Ignored/, File.binread('index.html'))
summary = File.binread('index.html')[%r[<summary.*Klass\.html.*</summary>.*</details>]m]
assert_match(%r[Klass/Inner\.html".*>Inner<], summary)
klassnav = File.binread('Klass.html')[%r[<div class="nav-section">.*<div id="class-metadata">]m]

klass = File.binread('Klass.html')
klassnav = klass[%r[<div class="nav-section">.*<div id="class-metadata">]m]
assert_match(
%r[<li>\s*<details open>\s*<summary>\s*<a href=\S+>Heading 1</a>\s*</summary>\s*<ul]m,
klassnav
Expand All @@ -122,6 +124,14 @@ def test_generate
%r[<li>\s*<a href=\S+>Heading 1.1.1.1</a>\s*</ul>\s*</details>\s*</li>]m,
klassnav
)

assert_match(/<h1 id="class-Klass-label-Heading\+1">Heading 1(?!\.)/,
klass[%r[<section class=\"description\">.*</section>]m])
toc = File.binread('table_of_contents.html')
assert_match(
%r[<a\s+href="Klass\.html#class-Klass-label-Heading\+1">Heading 1</a>]m,
toc[%r[<h2\s+id=\"classes\">.*(?=<h2\b)]m][%r[<a\s+href="Klass\.html".*(?=</li\b)]m]
)
end

def test_generate_page
Expand Down

0 comments on commit 3833d0f

Please sign in to comment.