Skip to content

Commit

Permalink
Expand the enclosing tree of the current file
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Mar 21, 2022
1 parent b7b4cda commit f9f90ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<%- simple_files = @files.select { |f| f.text? } %>
<%- if defined?(current) -%>
<%- dir = current.full_name[%r{\A[^/]+(?=/)}] || current.page_name -%>
<%- end -%>
<%- unless simple_files.empty? then -%>
<div id="fileindex-section" class="nav-section">
<h3>Pages</h3>
Expand All @@ -12,7 +15,7 @@
<li><a href="<%= rel_prefix %>/<%= f.path %>"><%= h f.page_name %></a>
<%- next -%>
<%- end -%>
<li><details><summary><%
<li><details<% if dir == n %> open<% end %>><summary><%
if n == f.page_name
%><a href="<%= rel_prefix %>/<%= f.path %>"><%= h n %></a><%
else
Expand Down
4 changes: 4 additions & 0 deletions test/rdoc/test_rdoc_generator_darkfish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ def test_generate_page
assert_match(re, index)
summary = index[re]
assert_match %r[<a href="\./outer/inner_rdoc.html">inner</a>], summary
re = %r[<details open><summary><a href="\./outer_rdoc\.html">outer</a></summary>.*?</details>]m
assert_match(re, File.read('outer_rdoc.html'))
re = %r[<details open><summary><a href="\.\./outer_rdoc\.html">outer</a></summary>.*?</details>]m
assert_match(re, File.read('outer/inner_rdoc.html'))
end

def test_generate_dry_run
Expand Down

0 comments on commit f9f90ef

Please sign in to comment.