Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase text contrast for dark mode #308

Merged
merged 4 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions lib/rdoc/generator/template/rails/resources/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ body {

@media (prefers-color-scheme: dark) {
:root {
--text-color: #ddd;
--text-color: #dddddd;
--link-color: #ee3f3f;

--body-bg: #222222;
--code-bg: #000000;
--body-bg: #0c0c0c;
--code-bg: #1b1b1b;
--source-code-bg: #000000;
}
}
Expand Down Expand Up @@ -69,7 +69,6 @@ a code {

.kind {
font-family: monospace;
font-weight: bold;
}

.kind::after {
Expand Down Expand Up @@ -520,7 +519,6 @@ html {
}

.method__signature {
font-size: 1.1em;
padding-bottom: var(--space-sm);
border-bottom: 2px solid var(--code-bg);

Expand All @@ -529,7 +527,7 @@ html {
}

.method__signature h3 {
font-size: 1em;
font-size: 1rem;
font-weight: normal;
white-space: pre-wrap;
}
Expand Down
10 changes: 5 additions & 5 deletions lib/sdoc/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ def module_ancestors(rdoc_module)

def method_signature(rdoc_method)
if rdoc_method.call_seq
rdoc_method.call_seq.split(/\n+/).map do |line|
# Support specifying a call-seq like `to_s -> string`
line.split(" -> ").map { |side| "<code>#{h side}</code>" }.join(" &rarr; ")
end.join("\n")
# Support specifying a call-seq like `to_s -> string`
rdoc_method.call_seq.gsub(/^\s*([^(\s]+)(.*?)(?: -> (.+))?$/) do
"<code><b>#{h $1}</b>#{h $2}</code>#{" &rarr; <code>#{h $3}</code>" if $3}"
end
else
"<code>#{h rdoc_method.name}#{h rdoc_method.params}</code>"
"<code><b>#{h rdoc_method.name}</b>#{h rdoc_method.params}</code>"
end
end

Expand Down
12 changes: 6 additions & 6 deletions spec/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,15 @@ class Foo; include M1; end
module Foo; def bar(qux); end; end
RUBY

_(@helpers.method_signature(method)).must_equal "<code>bar(qux)</code>"
_(@helpers.method_signature(method)).must_equal "<code><b>bar</b>(qux)</code>"
end

it "escapes the method signature" do
method = rdoc_top_level_for(<<~RUBY).find_module_named("Foo").find_method("bar", false)
module Foo; def bar(op = :<, &block); end; end
RUBY

_(@helpers.method_signature(method)).must_equal "<code>bar(op = :&lt;, &amp;block)</code>"
_(@helpers.method_signature(method)).must_equal "<code><b>bar</b>(op = :&lt;, &amp;block)</code>"
end

it "handles :call-seq: documentation" do
Expand All @@ -620,13 +620,13 @@ def qux(&block); end
RUBY

_(@helpers.method_signature(mod.find_method("bar", false))).must_equal <<~HTML.chomp
<code>bar(op = :&lt;)</code>
<code>bar(&amp;block)</code>
<code><b>bar</b>(op = :&lt;)</code>
<code><b>bar</b>(&amp;block)</code>
HTML

_(@helpers.method_signature(mod.find_method("qux", false))).must_equal <<~HTML.chomp
<code>qux(&amp;block)</code> &rarr; <code>self</code>
<code>qux</code> &rarr; <code>Enumerator</code>
<code><b>qux</b>(&amp;block)</code> &rarr; <code>self</code>
<code><b>qux</b></code> &rarr; <code>Enumerator</code>
HTML
end
end
Expand Down