Skip to content

Commit 7757fd9

Browse files
authored
Make methods and attributes linkable (#1189)
* Use the same color for both class/module and method highlight * Make methods and attributes linkable
1 parent e608a84 commit 7757fd9

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

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

+16-8
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@
7272
<%- attributes.each do |attrib| -%>
7373
<div id="<%= attrib.aref %>" class="method-detail">
7474
<div class="method-heading attribute-method-heading">
75-
<span class="method-name"><%= h attrib.name %></span><span
76-
class="attribute-access-type">[<%= attrib.rw %>]</span>
75+
<a href="#<%= attrib.aref %>" title="Link to this attribute">
76+
<span class="method-name"><%= h attrib.name %></span>
77+
<span class="attribute-access-type">[<%= attrib.rw %>]</span>
78+
</a>
7779
</div>
7880

7981
<div class="method-description">
@@ -103,21 +105,27 @@
103105
<%- if (call_seq = method.call_seq) then -%>
104106
<%- call_seq.strip.split("\n").each_with_index do |call_seq, i| -%>
105107
<div class="method-heading">
106-
<span class="method-callseq">
107-
<%= h(call_seq.strip.
108+
<a href="#<%= method.aref %>" title="Link to this method">
109+
<span class="method-callseq">
110+
<%= h(call_seq.strip.
108111
gsub( /^\w+\./m, '')).
109112
gsub(/(.*)[-=]&gt;/, '\1&rarr;') %>
110-
</span>
113+
</span>
114+
</a>
111115
</div>
112116
<%- end -%>
113117
<%- elsif method.has_call_seq? then -%>
114118
<div class="method-heading">
115-
<span class="method-name"><%= h method.name %></span>
119+
<a href="#<%= method.aref %>" title="Link to this method">
120+
<span class="method-name"><%= h method.name %></span>
121+
</a>
116122
</div>
117123
<%- else -%>
118124
<div class="method-heading">
119-
<span class="method-name"><%= h method.name %></span>
120-
<span class="method-args"><%= h method.param_seq %></span>
125+
<a href="#<%= method.aref %>" title="Link to this method">
126+
<span class="method-name"><%= h method.name %></span>
127+
<span class="method-args"><%= h method.param_seq %></span>
128+
</a>
121129
</div>
122130
<%- end -%>
123131
</div>

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

+13-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ h4:target,
8484
h5:target,
8585
h6:target {
8686
margin-left: -10px;
87-
border-left: 10px solid #f1edba;
87+
border-left: 10px solid var(--source-code-background-color);
8888
}
8989

9090
/* 4. Links */
@@ -631,6 +631,18 @@ main .method-heading {
631631
color: var(--text-color);
632632
}
633633

634+
main .method-heading::after {
635+
content: '¶';
636+
position: absolute;
637+
visibility: hidden;
638+
color: var(--secondary-color);
639+
font-size: 0.5em;
640+
}
641+
642+
main .method-heading:hover::after {
643+
visibility: visible;
644+
}
645+
634646
main .method-controls {
635647
line-height: 20px;
636648
float: right;
@@ -663,7 +675,6 @@ main #attribute-method-details .method-detail:hover {
663675
}
664676
main .attribute-access-type {
665677
text-transform: uppercase;
666-
padding: 0 1em;
667678
}
668679
/* @end */
669680

0 commit comments

Comments
 (0)