Skip to content

Commit e2fe488

Browse files
authored
Use scroll-margin-top on anchor targets (#1190)
This will make the anchor target easier to read.
1 parent 7398e5b commit e2fe488

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</nav>
1919

2020
<main role="main" aria-labelledby="<%=h klass.aref %>">
21-
<h1 id="<%=h klass.aref %>" class="<%= klass.type %>">
21+
<h1 id="<%=h klass.aref %>" class="anchor-link <%= klass.type %>">
2222
<%= klass.type %> <%= klass.full_name %>
2323
</h1>
2424

@@ -27,7 +27,7 @@
2727
</section>
2828

2929
<%- klass.each_section do |section, constants, attributes| -%>
30-
<section id="<%= section.aref %>" class="documentation-section">
30+
<section id="<%= section.aref %>" class="documentation-section anchor-link">
3131
<%- if section.title then -%>
3232
<header class="documentation-section-title">
3333
<h2>
@@ -70,7 +70,7 @@
7070
</header>
7171

7272
<%- attributes.each do |attrib| -%>
73-
<div id="<%= attrib.aref %>" class="method-detail">
73+
<div id="<%= attrib.aref %>" class="method-detail anchor-link">
7474
<div class="method-heading attribute-method-heading">
7575
<a href="#<%= attrib.aref %>" title="Link to this attribute">
7676
<span class="method-name"><%= h attrib.name %></span>
@@ -94,13 +94,13 @@
9494
next if visibilities.empty?
9595
visibilities.each do |visibility, methods|
9696
next if methods.empty? %>
97-
<section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section">
97+
<section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section anchor-link">
9898
<header>
9999
<h3><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</h3>
100100
</header>
101101

102102
<%- methods.each do |method| -%>
103-
<div id="<%= method.aref %>" class="method-detail <%= method.is_alias_for ? "method-alias" : '' %>">
103+
<div id="<%= method.aref %>" class="method-detail anchor-link <%= method.is_alias_for ? "method-alias" : '' %>">
104104
<div class="method-header">
105105
<%- if (call_seq = method.call_seq) then -%>
106106
<%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%>

lib/rdoc/generator/template/darkfish/css/rdoc.css

+4
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ main sup {
429429
font-size: 0.8em;
430430
}
431431

432+
main .anchor-link:target {
433+
scroll-margin-top: 20px;
434+
}
435+
432436
/* The heading with the class name */
433437
main h1[class] {
434438
margin-top: 0;

0 commit comments

Comments
 (0)