Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
<div id="classindex-section" class="nav-section">
<h3>Class and Module Index</h3>

<%-
all_classes = @classes.group_by do |klass|
klass.full_name[/\A[^:]++(?:::[^:]++(?=::))*+(?=::[^:]*+\z)/]
end.delete_if do |_, klasses|
!klasses.any?(&:display?)
end
link = proc do |index_klass, display = index_klass.display?|
if display
-%><code><a href="<%= rel_prefix %>/<%= index_klass.path %>"><%= index_klass.name %></a></code><%-
else
-%><code><%= index_klass.name %></code><%-
end
end
if top = all_classes[nil]
solo = top.one? {|klass| klass.display?}
traverse = proc do |klasses| -%>
<ul class="link-list">
<%- @modsort.each do |index_klass| -%>
<li><a href="<%= rel_prefix %>/<%= index_klass.path %>"><%= index_klass.full_name %></a>
<%- klasses.each do |index_klass| -%>
<%- if children = all_classes[index_klass.full_name] -%>
<li><details<% if solo; solo = false %> open<% end %>><summary><% link.call(index_klass) %></summary>
<%- traverse.call(children) -%>
</ul></details>
<%- elsif index_klass.display? -%>
<li><% link.call(index_klass, true) %>
<%- end -%>
<%- end -%>
<%- end -%>
<%- traverse.call(top) -%>
<%- end -%>
</ul>
</div>
16 changes: 16 additions & 0 deletions lib/rdoc/generator/template/darkfish/css/rdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,22 @@ main header h3 {

/* @group Method Details */

details summary {
display: block;
}
details summary::-webkit-details-marker {
display: none;
}
details summary:before {
content: "";
}
details summary:after {
content: " ▶";
}
details[open] > summary:after {
content: " ▽";
}

main .method-source-code {
max-height: 0;
overflow: hidden;
Expand Down
5 changes: 5 additions & 0 deletions test/rdoc/test_rdoc_generator_darkfish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ def teardown
def test_generate
top_level = @store.add_file 'file.rb'
top_level.add_class @klass.class, @klass.name
@klass.add_class RDoc::NormalClass, 'Inner'

@g.generate

assert_file 'index.html'
assert_file 'Object.html'
assert_file 'Klass.html'
assert_file 'Klass/Inner.html'
assert_file 'table_of_contents.html'
assert_file 'js/search_index.js'

Expand All @@ -92,6 +95,8 @@ def test_generate
assert_match %r%<meta charset="#{encoding}">%, File.read('Object.html')

refute_match(/Ignored/, File.read('index.html'))
summary = File.read('index.html')[%r[<summary.*Klass\.html.*</summary>.*</details>]m]
assert_match(%r[Klass/Inner\.html".*>Inner<], summary)
end

def test_generate_dry_run
Expand Down