Skip to content

Commit df9b2b0

Browse files
committed
Simplify class page
1 parent a815cc0 commit df9b2b0

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

lib/rdoc/generator/darkfish.rb

+11
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,23 @@ def generate_class klass, template_file = nil
355355

356356
@title = "#{klass.type} #{klass.full_name} - #{@options.title}"
357357

358+
klass_class_methods = klass.class_method_list.sort
359+
klass_instance_methods = klass.instance_methods.sort
360+
klass_extends = klass.extends
361+
klass_includes = klass.includes
362+
klass_sections = klass.sort_sections
363+
358364
debug_msg " rendering #{out_file}"
359365
render_template template_file, out_file do |io|
360366
here = binding
361367
here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)
362368
here.local_variable_set(:svninfo, svninfo)
363369
here.local_variable_set(:breadcrumb, breadcrumb)
370+
here.local_variable_set(:klass_class_methods, klass_class_methods)
371+
here.local_variable_set(:klass_instance_methods, klass_instance_methods)
372+
here.local_variable_set(:klass_extends, klass_extends)
373+
here.local_variable_set(:klass_includes, klass_includes)
374+
here.local_variable_set(:klass_sections, klass_sections)
364375
here
365376
end
366377
end

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

+16-16
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
<%= render '_sidebar_table_of_contents.rhtml' %>
1111

12-
<%- unless klass.sections.length == 1 then %>
12+
<%- if klass_sections.any? %>
1313
<div id="sections-section" class="nav-section">
1414
<h3>Sections</h3>
1515

1616
<ul class="link-list" role="directory">
17-
<%- klass.sort_sections.each do |section| -%>
17+
<%- klass_sections.each do |section| -%>
1818
<li><a href="#<%= section.aref %>"><%= h section.title %></a></li>
1919
<%- end -%>
2020
</ul>
@@ -28,54 +28,54 @@
2828
</div>
2929
<%- end -%>
3030

31-
<%- unless klass.includes.empty? then %>
31+
<%- if klass_includes.any? %>
3232
<div id="includes-section" class="nav-section">
3333
<h3>Included Modules</h3>
3434

3535
<ul class="link-list">
36-
<%- klass.each_include do |inc| -%>
37-
<%- unless String === inc.module then -%>
36+
<%- klass_includes.each do |inc| -%>
37+
<%- unless String === inc.module -%>
3838
<li><a class="include" href="<%= klass.aref_to inc.module.path %>"><%= inc.module.full_name %></a>
39-
<%- else -%>
39+
<%- else -%>
4040
<li><span class="include"><%= inc.name %></span>
41-
<%- end -%>
41+
<%- end -%>
4242
<%- end -%>
4343
</ul>
4444
</div>
4545
<%- end -%>
4646

47-
<%- unless klass.extends.empty? then %>
47+
<%- if klass_extends.any? %>
4848
<div id="extends-section" class="nav-section">
4949
<h3>Extended With Modules</h3>
5050

5151
<ul class="link-list">
52-
<%- klass.each_extend do |ext| -%>
53-
<%- unless String === ext.module then -%>
52+
<%- klass_extends.each do |ext| -%>
53+
<%- unless String === ext.module -%>
5454
<li><a class="extend" href="<%= klass.aref_to ext.module.path %>"><%= ext.module.full_name %></a>
55-
<%- else -%>
55+
<%- else -%>
5656
<li><span class="extend"><%= ext.name %></span>
57-
<%- end -%>
57+
<%- end -%>
5858
<%- end -%>
5959
</ul>
6060
</div>
6161
<%- end -%>
6262

63-
<% if (class_methods = klass.class_method_list.sort).any? %>
63+
<% if klass_class_methods.any? %>
6464
<div class="nav-section">
6565
<h3>Class Methods</h3>
6666
<ul class="link-list" role="directory">
67-
<%- class_methods.each do |meth| -%>
67+
<%- klass_class_methods.each do |meth| -%>
6868
<li <%- if meth.calls_super %>class="calls-super" <%- end %>><a href="#<%= meth.aref %>"><%= h meth.name -%></a></li>
6969
<%- end -%>
7070
</ul>
7171
</div>
7272
<% end %>
7373

74-
<% if (instance_methods = klass.instance_methods.sort).any? %>
74+
<% if klass_instance_methods.any? %>
7575
<div class="nav-section">
7676
<h3>Instance Methods</h3>
7777
<ul class="link-list" role="directory">
78-
<%- instance_methods.each do |meth| -%>
78+
<%- klass_instance_methods.each do |meth| -%>
7979
<li <%- if meth.calls_super %>class="calls-super" <%- end %>><a href="#<%= meth.aref %>"><%= h meth.name -%></a></li>
8080
<%- end -%>
8181
</ul>

0 commit comments

Comments
 (0)