Skip to content

Commit

Permalink
Use scroll-margin-top on anchor targets (#1190)
Browse files Browse the repository at this point in the history
This will make the anchor target easier to read.
  • Loading branch information
st0012 authored Oct 17, 2024
1 parent 7398e5b commit e2fe488
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/rdoc/generator/template/darkfish/class.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</nav>

<main role="main" aria-labelledby="<%=h klass.aref %>">
<h1 id="<%=h klass.aref %>" class="<%= klass.type %>">
<h1 id="<%=h klass.aref %>" class="anchor-link <%= klass.type %>">
<%= klass.type %> <%= klass.full_name %>
</h1>

Expand All @@ -27,7 +27,7 @@
</section>

<%- klass.each_section do |section, constants, attributes| -%>
<section id="<%= section.aref %>" class="documentation-section">
<section id="<%= section.aref %>" class="documentation-section anchor-link">
<%- if section.title then -%>
<header class="documentation-section-title">
<h2>
Expand Down Expand Up @@ -70,7 +70,7 @@
</header>

<%- attributes.each do |attrib| -%>
<div id="<%= attrib.aref %>" class="method-detail">
<div id="<%= attrib.aref %>" class="method-detail anchor-link">
<div class="method-heading attribute-method-heading">
<a href="#<%= attrib.aref %>" title="Link to this attribute">
<span class="method-name"><%= h attrib.name %></span>
Expand All @@ -94,13 +94,13 @@
next if visibilities.empty?
visibilities.each do |visibility, methods|
next if methods.empty? %>
<section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section">
<section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section anchor-link">
<header>
<h3><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</h3>
</header>

<%- methods.each do |method| -%>
<div id="<%= method.aref %>" class="method-detail <%= method.is_alias_for ? "method-alias" : '' %>">
<div id="<%= method.aref %>" class="method-detail anchor-link <%= method.is_alias_for ? "method-alias" : '' %>">
<div class="method-header">
<%- if (call_seq = method.call_seq) then -%>
<%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%>
Expand Down
4 changes: 4 additions & 0 deletions lib/rdoc/generator/template/darkfish/css/rdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ main sup {
font-size: 0.8em;
}

main .anchor-link:target {
scroll-margin-top: 20px;
}

/* The heading with the class name */
main h1[class] {
margin-top: 0;
Expand Down

0 comments on commit e2fe488

Please sign in to comment.