Skip to content

Commit b7b4cda

Browse files
committed
Fold files in the page directory
1 parent c870284 commit b7b4cda

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,25 @@
44
<h3>Pages</h3>
55

66
<ul class="link-list">
7-
<%- simple_files.each do |f| -%>
7+
<%- simple_files.group_by do |f| -%>
8+
<%- f.full_name[%r{\A[^/]+(?=/)}] || f.page_name -%>
9+
<%- end.each do |n, files| -%>
10+
<%- f = files.shift -%>
11+
<%- if files.empty? -%>
812
<li><a href="<%= rel_prefix %>/<%= f.path %>"><%= h f.page_name %></a>
13+
<%- next -%>
14+
<%- end -%>
15+
<li><details><summary><%
16+
if n == f.page_name
17+
%><a href="<%= rel_prefix %>/<%= f.path %>"><%= h n %></a><%
18+
else
19+
%><%= h n %><% files.unshift(f)
20+
end %></summary>
21+
<ul class="link-list">
22+
<%- files.each do |f| -%>
23+
<li><a href="<%= rel_prefix %>/<%= f.path %>"><%= h f.page_name %></a>
24+
<%- end -%>
25+
</ul></details>
926
<%- end -%>
1027
</ul>
1128
</div>

test/rdoc/test_rdoc_generator_darkfish.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ def test_generate_page
105105
@g.generate
106106
assert_file 'outer_rdoc.html'
107107
assert_file 'outer/inner_rdoc.html'
108+
index = File.read('index.html')
109+
re = %r[<summary><a href="\./outer_rdoc\.html">outer</a></summary>.*?</details>]m
110+
assert_match(re, index)
111+
summary = index[re]
112+
assert_match %r[<a href="\./outer/inner_rdoc.html">inner</a>], summary
108113
end
109114

110115
def test_generate_dry_run

0 commit comments

Comments
 (0)