Skip to content
Open
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
12 changes: 12 additions & 0 deletions lib/rdoc/generator/template/aliki/class.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@
<%- unless constants.empty? %>
<section class="constants-list">
<header>
<%- if section.title %>
<h3 id="<%= section.aref %>-constants"><a href="#<%= section.aref %>-constants">Constants</a></h3>
<%- else %>
<h2 id="<%= section.aref %>-constants"><a href="#<%= section.aref %>-constants">Constants</a></h2>
Comment thread
st0012 marked this conversation as resolved.
<%- end %>
</header>
<dl>
<%- constants.each do |const| %>
Expand All @@ -84,7 +88,11 @@
<%- unless attributes.empty? %>
<section class="attribute-method-details method-section">
<header>
<%- if section.title %>
<h3 id="<%= section.aref %>-attributes"><a href="#<%= section.aref %>-attributes">Attributes</a></h3>
<%- else %>
<h2 id="<%= section.aref %>-attributes"><a href="#<%= section.aref %>-attributes">Attributes</a></h2>
<%- end %>
</header>

<%- attributes.each do |attrib| %>
Expand Down Expand Up @@ -122,7 +130,11 @@
<%- next if methods.empty? %>
<section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section anchor-link">
<header>
<%- if section.title %>
<h3 id="<%= visibility %>-<%= type %>-<%= section.aref %>-methods"><a href="#<%= visibility %>-<%= type %>-<%= section.aref %>-methods"><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</a></h3>
<%- else %>
<h2 id="<%= visibility %>-<%= type %>-<%= section.aref %>-methods"><a href="#<%= visibility %>-<%= type %>-<%= section.aref %>-methods"><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</a></h2>
<%- end %>
</header>

<%- methods.each do |method| %>
Expand Down
22 changes: 22 additions & 0 deletions test/rdoc/generator/aliki_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,28 @@ def test_aliased_classes_full_name
assert_equal(%w[Klass Klass::A Object], @g.classes.map(&:full_name).sort)
end

def test_class_section_heading_levels
@klass.add_constant RDoc::Constant.new('DEFAULT', '1', '')
@klass.add_attribute RDoc::Attr.new('default_attr', 'R', '')

@klass.set_current_section 'Utilities', nil
@klass.add_constant RDoc::Constant.new('NAMED', '2', '')
@klass.add_attribute RDoc::Attr.new('named_attr', 'R', '')
@klass.add_method RDoc::AnyMethod.new('named_method')

@g.generate

content = File.binread('Klass.html')

assert_include content, '<h2 id="untitled-constants">'
assert_include content, '<h2 id="untitled-attributes">'
assert_include content, '<h2 id="public-instance-untitled-methods">'
assert_include content, '<h2 id="utilities">'
assert_include content, '<h3 id="utilities-constants">'
assert_include content, '<h3 id="utilities-attributes">'
assert_include content, '<h3 id="public-instance-utilities-methods">'
end

def test_write_style_sheet_copies_css_and_js_only
@g.generate

Expand Down
Loading