Skip to content

Commit 9c63b36

Browse files
committed
Style linked types with consistent underline
1 parent df1587c commit 9c63b36

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

lib/rdoc/generator/template/aliki/css/rdoc.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,11 +1076,14 @@ main h6 a:hover {
10761076
.rbs-builtin { color: var(--code-purple); }
10771077

10781078
a.rbs-type {
1079-
text-decoration: none;
1079+
text-decoration: underline;
1080+
text-decoration-color: var(--color-border-default);
1081+
text-underline-offset: 0.2em;
1082+
transition: text-decoration-color var(--transition-fast);
10801083
}
10811084

10821085
a.rbs-type:hover {
1083-
text-decoration: underline;
1086+
text-decoration-color: currentColor;
10841087
}
10851088

10861089
/* Emphasis */

lib/rdoc/generator/template/aliki/js/rbs_highlighter.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@
9999
}
100100

101101
function initHighlighting() {
102+
var elements = document.querySelectorAll('.method-type-signature code');
103+
if (elements.length === 0) return;
104+
102105
typeLookup = buildTypeLookup();
103106

104-
document.querySelectorAll('.method-type-signature code').forEach(function(el) {
107+
elements.forEach(function(el) {
105108
if (el.getAttribute('data-highlighted') === 'true') return;
106109
el.innerHTML = highlightRbs(el.textContent); // eslint-disable-line no-unsanitized/property
107110
el.setAttribute('data-highlighted', 'true');

lib/rdoc/parser/prism_ruby.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,6 @@ def consecutive_comment(line_no)
486486

487487
private def validate_type_signature(sig)
488488
sig.split("\n").each do |line|
489-
# Method types contain ->, plain types (for attributes) don't
490489
error = if line.include?('->')
491490
RDoc::RbsSupport.validate_method_type(line)
492491
else

lib/rdoc/rbs_support.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,17 @@ def self.merge_into_store(store, signatures)
7474
next if method.type_signature
7575

7676
key = method.singleton ? "#{cm.full_name}::#{method.name}" : "#{cm.full_name}##{method.name}"
77-
method.type_signature = signatures[key] if signatures[key]
77+
if (sig = signatures[key])
78+
method.type_signature = sig
79+
end
7880
end
7981

8082
cm.attributes.each do |attr|
8183
next if attr.type_signature
8284

83-
key = "#{cm.full_name}.#{attr.name}"
84-
attr.type_signature = signatures[key] if signatures[key]
85+
if (sig = signatures["#{cm.full_name}.#{attr.name}"])
86+
attr.type_signature = sig
87+
end
8588
end
8689
end
8790
end

0 commit comments

Comments
 (0)