[ruby/rdoc] Fold files in the page directory

https://github.com/ruby/rdoc/commit/b7b4cdab6c
This commit is contained in:
Nobuyoshi Nakada 2022-03-13 21:16:43 +09:00 committed by git
parent 034c09776d
commit dafe5c1323
2 changed files with 23 additions and 1 deletions

View File

@ -4,8 +4,25 @@
<h3>Pages</h3>
<ul class="link-list">
<%- simple_files.each do |f| -%>
<%- simple_files.group_by do |f| -%>
<%- f.full_name[%r{\A[^/]+(?=/)}] || f.page_name -%>
<%- end.each do |n, files| -%>
<%- f = files.shift -%>
<%- if files.empty? -%>
<li><a href="<%= rel_prefix %>/<%= f.path %>"><%= h f.page_name %></a>
<%- next -%>
<%- end -%>
<li><details><summary><%
if n == f.page_name
%><a href="<%= rel_prefix %>/<%= f.path %>"><%= h n %></a><%
else
%><%= h n %><% files.unshift(f)
end %></summary>
<ul class="link-list">
<%- files.each do |f| -%>
<li><a href="<%= rel_prefix %>/<%= f.path %>"><%= h f.page_name %></a>
<%- end -%>
</ul></details>
<%- end -%>
</ul>
</div>

View File

@ -105,6 +105,11 @@ class TestRDocGeneratorDarkfish < RDoc::TestCase
@g.generate
assert_file 'outer_rdoc.html'
assert_file 'outer/inner_rdoc.html'
index = File.read('index.html')
re = %r[<summary><a href="\./outer_rdoc\.html">outer</a></summary>.*?</details>]m
assert_match(re, index)
summary = index[re]
assert_match %r[<a href="\./outer/inner_rdoc.html">inner</a>], summary
end
def test_generate_dry_run