Skip to content
Draft
275 changes: 150 additions & 125 deletions lib/rdoc/generator/darkfish.rb

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml

This file was deleted.

15 changes: 0 additions & 15 deletions lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml

This file was deleted.

21 changes: 0 additions & 21 deletions lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml

This file was deleted.

29 changes: 2 additions & 27 deletions lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml
Original file line number Diff line number Diff line change
@@ -1,32 +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 -%>
<%- if @page_files.any? -%>
<div id="fileindex-section" class="nav-section">
<h3>Pages</h3>

<ul class="link-list">
<%- 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 %>/<%= h f.path %>"><%= h f.page_name %></a>
<%- next -%>
<%- end -%>
<li><details<% if dir == n %> open<% end %>><summary><%
if n == f.page_name
%><a href="<%= rel_prefix %>/<%= h 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 %>/<%= h f.path %>"><%= h f.page_name %></a>
<%- end -%>
</ul></details>
<%- end -%>
</ul>
<%= generate_pages_index_content(@page_files, rel_prefix, target) %>
</div>
<%- end -%>
6 changes: 0 additions & 6 deletions lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml

This file was deleted.

11 changes: 0 additions & 11 deletions lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
<%- comment = if current.respond_to? :comment_location then
current.comment_location
else
current.comment
end
table = current.parse(comment).table_of_contents.dup

if table.length > 1 then %>
<%- table = generate_table_from_target(target) -%>
<%- if table.length > 1 %>
<div class="nav-section">
<h3>Table of Contents</h3>

<%- display_link = proc do |heading| -%>
<a href="#<%= heading.label current %>"><%= heading.plain_html %></a>
<a href="#<%= heading.label target %>"><%= heading.plain_html %></a>
<%- end -%>

<%- list_siblings = proc do -%>
Expand Down
78 changes: 73 additions & 5 deletions lib/rdoc/generator/template/darkfish/class.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,79 @@
</div>

<%= render '_sidebar_table_of_contents.rhtml' %>
<%= render '_sidebar_sections.rhtml' %>
<%= render '_sidebar_parent.rhtml' %>
<%= render '_sidebar_includes.rhtml' %>
<%= render '_sidebar_extends.rhtml' %>
<%= render '_sidebar_methods.rhtml' %>

<%- if klass_sections.any? %>
<div id="sections-section" class="nav-section">
<h3>Sections</h3>

<ul class="link-list" role="directory">
<%- klass_sections.each do |section| -%>
<li><a href="#<%= section.aref %>"><%= h section.title %></a></li>
<%- end -%>
</ul>
</div>
<%- end -%>

<%- if klass.type == 'class' && (ancestors = klass.super_classes).any? -%>
<div id="parent-class-section" class="nav-section">
<h3>Ancestors</h3>
<%= generate_ancestor_list(ancestors, klass) %>
</div>
<%- end -%>

<%- if klass_includes.any? %>
<div id="includes-section" class="nav-section">
<h3>Included Modules</h3>

<ul class="link-list">
<%- klass_includes.each do |inc| -%>
<%- unless String === inc.module -%>
<li><a class="include" href="<%= klass.aref_to inc.module.path %>"><%= inc.module.full_name %></a>
<%- else -%>
<li><span class="include"><%= inc.name %></span>
<%- end -%>
<%- end -%>
</ul>
</div>
<%- end -%>

<%- if klass_extends.any? %>
<div id="extends-section" class="nav-section">
<h3>Extended With Modules</h3>

<ul class="link-list">
<%- klass_extends.each do |ext| -%>
<%- unless String === ext.module -%>
<li><a class="extend" href="<%= klass.aref_to ext.module.path %>"><%= ext.module.full_name %></a>
<%- else -%>
<li><span class="extend"><%= ext.name %></span>
<%- end -%>
<%- end -%>
</ul>
</div>
<%- end -%>

<% if klass_class_methods.any? %>
<div class="nav-section">
<h3>Class Methods</h3>
<ul class="link-list" role="directory">
<%- klass_class_methods.each do |meth| -%>
<li <%- if meth.calls_super %>class="calls-super" <%- end %>><a href="#<%= meth.aref %>"><%= h meth.name -%></a></li>
<%- end -%>
</ul>
</div>
<% end %>

<% if klass_instance_methods.any? %>
<div class="nav-section">
<h3>Instance Methods</h3>
<ul class="link-list" role="directory">
<%- klass_instance_methods.each do |meth| -%>
<li <%- if meth.calls_super %>class="calls-super" <%- end %>><a href="#<%= meth.aref %>"><%= h meth.name -%></a></li>
<%- end -%>
</ul>
</div>
<% end %>

<%= render '_footer.rhtml' %>
</nav>
Expand Down
2 changes: 1 addition & 1 deletion lib/rdoc/generator/template/darkfish/index.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render '_sidebar_search.rhtml' %>
</div>

<%= render '_sidebar_table_of_contents.rhtml' if defined?(current) %>
<%= render '_sidebar_table_of_contents.rhtml' %>
<%= render '_sidebar_pages.rhtml' %>
<%= render '_sidebar_classes.rhtml' %>

Expand Down
11 changes: 4 additions & 7 deletions lib/rdoc/generator/template/darkfish/table_of_contents.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
<main role="main">
<h1 class="class"><%= h @title %></h1>

<%- simple_files = @files.select { |f| f.text? } -%>
<%- unless simple_files.empty? then -%>
<%- if @page_files.any? -%>
<h2 id="pages">Pages</h2>
<ul>
<%- simple_files.sort.each do |file| -%>
<%- @page_files.sort.each do |file| -%>
<li class="file">
<a href="<%= h file.path %>"><%= h file.page_name %></a>
<%
Expand All @@ -37,7 +36,7 @@

<h2 id="classes">Classes and Modules</h2>
<ul>
<%- @modsort.each do |klass| -%>
<%- @classes.select(&:display?).each do |klass| -%>
<li class="<%= klass.type %>">
<a href="<%= klass.path %>"><%= klass.full_name %></a>
<%- table = []
Expand All @@ -58,9 +57,7 @@

<h2 id="methods">Methods</h2>
<ul>
<%- @store.all_classes_and_modules.flat_map do |mod|
mod.method_list
end.sort.each do |method| %>
<%- @classes.flat_map(&:method_list).sort.each do |method| %>
<li class="method">
<a href="<%= method.path %>"><%= h method.pretty_name %></a>
&mdash;
Expand Down
2 changes: 0 additions & 2 deletions test/rdoc/test_rdoc_generator_darkfish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ def test_setup
assert_equal [@klass_alias, @ignored, @klass, @object],
@g.classes.sort_by { |klass| klass.full_name }
assert_equal [@top_level], @g.files
assert_equal [@meth, @meth, @meth_bang, @meth_bang, @meth_with_html_tag_yield, @meth_with_html_tag_yield], @g.methods
assert_equal [@klass_alias, @klass, @object], @g.modsort
end

def test_template_for
Expand Down
Loading