Skip to content

Commit 26f0cc4

Browse files
authored
Add unique IDs to section headings in Aliki template (#1603)
The Aliki TOC is generated by JavaScript that scans h1/h2/h3 elements with IDs. Section title h2 elements had no ID, so they were invisible to the TOC. Meanwhile, h3 IDs like "constants" and "public-instance-methods" were duplicated across sections. Prefix all heading IDs with the section's aref to make them unique. Move the section ID from the `<section>` element to the `<h2>` so the TOC picks it up naturally. <img width="250" height="291" alt="Screenshot 2026-02-08 at 10 20 30" src="https://github.com/user-attachments/assets/b399fb90-ff1a-46b9-838c-61576c6acc2c" /> Fixes #1598
1 parent 0566dac commit 26f0cc4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040

4141
<%- klass.each_section do |section, constants, attributes| %>
4242
<span id="<%= section.legacy_aref %>" class="legacy-anchor"></span>
43-
<section id="<%= section.aref %>" class="documentation-section anchor-link">
43+
<section class="documentation-section anchor-link">
4444
<%- if section.title then %>
4545
<header class="documentation-section-title">
46-
<h2>
46+
<h2 id="<%= section.aref %>">
4747
<a href="#<%= section.aref %>"><%= section.title %></a>
4848
</h2>
4949
</header>
@@ -58,7 +58,7 @@
5858
<%- unless constants.empty? then %>
5959
<section class="constants-list">
6060
<header>
61-
<h3 id="constants"><a href="#constants">Constants</a></h3>
61+
<h3 id="<%= section.aref %>-constants"><a href="#<%= section.aref %>-constants">Constants</a></h3>
6262
</header>
6363
<dl>
6464
<%- constants.each do |const| %>
@@ -83,7 +83,7 @@
8383
<%- unless attributes.empty? then %>
8484
<section class="attribute-method-details method-section">
8585
<header>
86-
<h3 id="attributes"><a href="#attributes">Attributes</a></h3>
86+
<h3 id="<%= section.aref %>-attributes"><a href="#<%= section.aref %>-attributes">Attributes</a></h3>
8787
</header>
8888

8989
<%- attributes.each do |attrib| %>
@@ -118,7 +118,7 @@
118118
<%- next if methods.empty? %>
119119
<section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section anchor-link">
120120
<header>
121-
<h3 id="<%= visibility %>-<%= type %>-methods"><a href="#<%= visibility %>-<%= type %>-methods"><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</a></h3>
121+
<h3 id="<%= visibility %>-<%= type %>-<%= section.aref %>-methods"><a href="#<%= visibility %>-<%= type %>-<%= section.aref %>-methods"><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</a></h3>
122122
</header>
123123

124124
<%- methods.each do |method| %>

0 commit comments

Comments
 (0)