Skip to content

Commit 40d8337

Browse files
committed
refactor: rename definition_color to strong_color for accuracy
The option applies to all <strong>/<b> elements, not just definitions. Sphinx renders actual definitions via <dl>/<dt> elements which can be targeted separately. Renamed across SCSS, theme.conf, layout.html, tests, and documentation.
1 parent 59d2d5e commit 40d8337

File tree

6 files changed

+60
-60
lines changed

6 files changed

+60
-60
lines changed

docs/configure.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ html_theme_options = {
338338
...
339339
"emphasis_color": "#1a73e8",
340340
"emphasis_color_dark": "#8ab4f8",
341-
"definition_color": "#d93025",
342-
"definition_color_dark": "#f28b82",
341+
"strong_color": "#d93025",
342+
"strong_color_dark": "#f28b82",
343343
...
344344
}
345345
```
@@ -352,15 +352,15 @@ sphinx:
352352
html_theme_options:
353353
emphasis_color: "#1a73e8"
354354
emphasis_color_dark: "#8ab4f8"
355-
definition_color: "#d93025"
356-
definition_color_dark: "#f28b82"
355+
strong_color: "#d93025"
356+
strong_color_dark: "#f28b82"
357357
```
358358

359359
| Option | Description | Default |
360360
|---|---|---|
361361
| `emphasis_color` | Color for `em` tags in light mode | `#2d9f42` (green) |
362362
| `emphasis_color_dark` | Color for `em` tags in dark mode | `#66bb6a` (light green) |
363-
| `definition_color` | Color for `strong`/`b` tags in light mode | `#8b4513` (brown) |
364-
| `definition_color_dark` | Color for `strong`/`b` tags in dark mode | `#cd853f` (peru) |
363+
| `strong_color` | Color for `strong`/`b` tags in light mode | `#8b4513` (brown) |
364+
| `strong_color_dark` | Color for `strong`/`b` tags in dark mode | `#cd853f` (peru) |
365365

366366
Any option left empty will use the theme's built-in default color.

src/quantecon_book_theme/assets/styles/_base.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ em {
154154
color: var(--qe-emphasis-color, colors.$emphasis);
155155
}
156156

157-
// Strong/bold styling - semi-bold weight with color for definitions
157+
// Strong/bold styling - semi-bold weight with color
158158
strong,
159159
b {
160160
font-weight: 550;
161-
color: var(--qe-definition-color, colors.$definition);
161+
color: var(--qe-strong-color, colors.$definition);
162162
}
163163

164164
li {

src/quantecon_book_theme/assets/styles/_dark-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ body.dark-theme {
2828

2929
strong,
3030
b {
31-
color: var(--qe-definition-color, #cd853f); // Lighter brown for dark mode
31+
color: var(--qe-strong-color, #cd853f); // Lighter brown for dark mode
3232
}
3333

3434
.qe-toolbar__inner > ul > li > a,

src/quantecon_book_theme/theme/quantecon_book_theme/layout.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,24 @@
121121
</style>
122122
{%- endif %}
123123

124-
<!-- Custom emphasis and definition colors -->
125-
{%- if theme_emphasis_color or theme_definition_color %}
124+
<!-- Custom emphasis and strong/bold colors -->
125+
{%- if theme_emphasis_color or theme_strong_color %}
126126
<style>
127127
:root {
128128
{%- if theme_emphasis_color %}
129129
--qe-emphasis-color: {{ theme_emphasis_color }};
130130
{%- endif %}
131-
{%- if theme_definition_color %}
132-
--qe-definition-color: {{ theme_definition_color }};
131+
{%- if theme_strong_color %}
132+
--qe-strong-color: {{ theme_strong_color }};
133133
{%- endif %}
134134
}
135-
{%- if theme_emphasis_color_dark or theme_definition_color_dark %}
135+
{%- if theme_emphasis_color_dark or theme_strong_color_dark %}
136136
body.dark-theme {
137137
{%- if theme_emphasis_color_dark %}
138138
--qe-emphasis-color: {{ theme_emphasis_color_dark }};
139139
{%- endif %}
140-
{%- if theme_definition_color_dark %}
141-
--qe-definition-color: {{ theme_definition_color_dark }};
140+
{%- if theme_strong_color_dark %}
141+
--qe-strong-color: {{ theme_strong_color_dark }};
142142
{%- endif %}
143143
}
144144
{%- endif %}

src/quantecon_book_theme/theme/quantecon_book_theme/theme.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ use_repository_button = False
3939

4040
emphasis_color =
4141
emphasis_color_dark =
42-
definition_color =
43-
definition_color_dark =
42+
strong_color =
43+
strong_color_dark =

tests/test_custom_colors.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Tests for customizable emphasis and definition text colors.
2+
Tests for customizable emphasis and strong/bold text colors.
33
44
Verifies that:
55
- Theme options are registered in theme.conf
@@ -29,24 +29,24 @@ def test_emphasis_color_dark_option_exists(self):
2929
content = (THEME_DIR / "theme.conf").read_text()
3030
assert "emphasis_color_dark =" in content
3131

32-
def test_definition_color_option_exists(self):
33-
"""theme.conf should define definition_color option."""
32+
def test_strong_color_option_exists(self):
33+
"""theme.conf should define strong_color option."""
3434
content = (THEME_DIR / "theme.conf").read_text()
35-
assert "definition_color =" in content
35+
assert "strong_color =" in content
3636

37-
def test_definition_color_dark_option_exists(self):
38-
"""theme.conf should define definition_color_dark option."""
37+
def test_strong_color_dark_option_exists(self):
38+
"""theme.conf should define strong_color_dark option."""
3939
content = (THEME_DIR / "theme.conf").read_text()
40-
assert "definition_color_dark =" in content
40+
assert "strong_color_dark =" in content
4141

4242
def test_options_default_to_empty(self):
4343
"""All color options should default to empty (use CSS fallback)."""
4444
content = (THEME_DIR / "theme.conf").read_text()
4545
for option in [
4646
"emphasis_color",
4747
"emphasis_color_dark",
48-
"definition_color",
49-
"definition_color_dark",
48+
"strong_color",
49+
"strong_color_dark",
5050
]:
5151
# Each option should appear as "option_name =" with no value
5252
# Use a targeted check to avoid matching substrings
@@ -55,53 +55,53 @@ def test_options_default_to_empty(self):
5555
line for line in lines if line.strip().startswith(f"{option} =")
5656
]
5757
assert len(matching) == 1, f"Expected exactly one '{option}' option"
58-
assert matching[0].strip() == f"{option} =", (
59-
f"'{option}' should default to empty string"
60-
)
58+
assert (
59+
matching[0].strip() == f"{option} ="
60+
), f"'{option}' should default to empty string"
6161

6262

6363
class TestCustomColorCSSVariables:
64-
"""Test that SCSS uses CSS custom properties for emphasis/definition."""
64+
"""Test that SCSS uses CSS custom properties for emphasis/strong."""
6565

6666
def test_base_scss_uses_emphasis_variable(self):
6767
"""_base.scss should use --qe-emphasis-color CSS variable for em."""
6868
content = (ASSETS_DIR / "styles" / "_base.scss").read_text()
6969
assert "var(--qe-emphasis-color" in content
7070

71-
def test_base_scss_uses_definition_variable(self):
72-
"""_base.scss should use --qe-definition-color CSS variable for strong."""
71+
def test_base_scss_uses_strong_variable(self):
72+
"""_base.scss should use --qe-strong-color CSS variable for strong."""
7373
content = (ASSETS_DIR / "styles" / "_base.scss").read_text()
74-
assert "var(--qe-definition-color" in content
74+
assert "var(--qe-strong-color" in content
7575

7676
def test_base_scss_has_emphasis_fallback(self):
7777
"""_base.scss should have SCSS fallback value for emphasis color."""
7878
content = (ASSETS_DIR / "styles" / "_base.scss").read_text()
7979
assert "var(--qe-emphasis-color, colors.$emphasis)" in content
8080

81-
def test_base_scss_has_definition_fallback(self):
82-
"""_base.scss should have SCSS fallback value for definition color."""
81+
def test_base_scss_has_strong_fallback(self):
82+
"""_base.scss should have SCSS fallback value for strong color."""
8383
content = (ASSETS_DIR / "styles" / "_base.scss").read_text()
84-
assert "var(--qe-definition-color, colors.$definition)" in content
84+
assert "var(--qe-strong-color, colors.$definition)" in content
8585

8686
def test_dark_theme_uses_emphasis_variable(self):
8787
"""_dark-theme.scss should use --qe-emphasis-color CSS variable."""
8888
content = (ASSETS_DIR / "styles" / "_dark-theme.scss").read_text()
8989
assert "var(--qe-emphasis-color" in content
9090

91-
def test_dark_theme_uses_definition_variable(self):
92-
"""_dark-theme.scss should use --qe-definition-color CSS variable."""
91+
def test_dark_theme_uses_strong_variable(self):
92+
"""_dark-theme.scss should use --qe-strong-color CSS variable."""
9393
content = (ASSETS_DIR / "styles" / "_dark-theme.scss").read_text()
94-
assert "var(--qe-definition-color" in content
94+
assert "var(--qe-strong-color" in content
9595

9696
def test_dark_theme_has_emphasis_fallback(self):
9797
"""_dark-theme.scss should have fallback for emphasis in dark mode."""
9898
content = (ASSETS_DIR / "styles" / "_dark-theme.scss").read_text()
9999
assert "var(--qe-emphasis-color, #66bb6a)" in content
100100

101-
def test_dark_theme_has_definition_fallback(self):
102-
"""_dark-theme.scss should have fallback for definition in dark mode."""
101+
def test_dark_theme_has_strong_fallback(self):
102+
"""_dark-theme.scss should have fallback for strong in dark mode."""
103103
content = (ASSETS_DIR / "styles" / "_dark-theme.scss").read_text()
104-
assert "var(--qe-definition-color, #cd853f)" in content
104+
assert "var(--qe-strong-color, #cd853f)" in content
105105

106106

107107
class TestCustomColorCompiledCSS:
@@ -113,11 +113,11 @@ def test_compiled_css_has_emphasis_variable(self):
113113
content = css_path.read_text()
114114
assert "--qe-emphasis-color" in content
115115

116-
def test_compiled_css_has_definition_variable(self):
117-
"""Compiled CSS should contain --qe-definition-color variable."""
116+
def test_compiled_css_has_strong_variable(self):
117+
"""Compiled CSS should contain --qe-strong-color variable."""
118118
css_path = THEME_DIR / "static" / "styles" / "quantecon-book-theme.css"
119119
content = css_path.read_text()
120-
assert "--qe-definition-color" in content
120+
assert "--qe-strong-color" in content
121121

122122
def test_compiled_css_em_uses_variable(self):
123123
"""Compiled CSS em rule should use var(--qe-emphasis-color)."""
@@ -126,10 +126,10 @@ def test_compiled_css_em_uses_variable(self):
126126
assert "var(--qe-emphasis-color" in content
127127

128128
def test_compiled_css_strong_uses_variable(self):
129-
"""Compiled CSS strong rule should use var(--qe-definition-color)."""
129+
"""Compiled CSS strong rule should use var(--qe-strong-color)."""
130130
css_path = THEME_DIR / "static" / "styles" / "quantecon-book-theme.css"
131131
content = css_path.read_text()
132-
assert "var(--qe-definition-color" in content
132+
assert "var(--qe-strong-color" in content
133133

134134

135135
class TestCustomColorLayoutTemplate:
@@ -143,40 +143,40 @@ def test_template_checks_emphasis_color(self):
143143
content = self._read_layout()
144144
assert "theme_emphasis_color" in content
145145

146-
def test_template_checks_definition_color(self):
147-
"""Layout template should conditionally check theme_definition_color."""
146+
def test_template_checks_strong_color(self):
147+
"""Layout template should conditionally check theme_strong_color."""
148148
content = self._read_layout()
149-
assert "theme_definition_color" in content
149+
assert "theme_strong_color" in content
150150

151151
def test_template_checks_emphasis_color_dark(self):
152152
"""Layout template should conditionally check theme_emphasis_color_dark."""
153153
content = self._read_layout()
154154
assert "theme_emphasis_color_dark" in content
155155

156-
def test_template_checks_definition_color_dark(self):
157-
"""Layout template should conditionally check theme_definition_color_dark."""
156+
def test_template_checks_strong_color_dark(self):
157+
"""Layout template should conditionally check theme_strong_color_dark."""
158158
content = self._read_layout()
159-
assert "theme_definition_color_dark" in content
159+
assert "theme_strong_color_dark" in content
160160

161161
def test_template_sets_emphasis_css_variable(self):
162162
"""Layout template should set --qe-emphasis-color CSS variable."""
163163
content = self._read_layout()
164164
assert "--qe-emphasis-color: {{ theme_emphasis_color }}" in content
165165

166-
def test_template_sets_definition_css_variable(self):
167-
"""Layout template should set --qe-definition-color CSS variable."""
166+
def test_template_sets_strong_css_variable(self):
167+
"""Layout template should set --qe-strong-color CSS variable."""
168168
content = self._read_layout()
169-
assert "--qe-definition-color: {{ theme_definition_color }}" in content
169+
assert "--qe-strong-color: {{ theme_strong_color }}" in content
170170

171171
def test_template_sets_dark_emphasis_css_variable(self):
172172
"""Layout template should set --qe-emphasis-color for dark mode."""
173173
content = self._read_layout()
174174
assert "--qe-emphasis-color: {{ theme_emphasis_color_dark }}" in content
175175

176-
def test_template_sets_dark_definition_css_variable(self):
177-
"""Layout template should set --qe-definition-color for dark mode."""
176+
def test_template_sets_dark_strong_css_variable(self):
177+
"""Layout template should set --qe-strong-color for dark mode."""
178178
content = self._read_layout()
179-
assert "--qe-definition-color: {{ theme_definition_color_dark }}" in content
179+
assert "--qe-strong-color: {{ theme_strong_color_dark }}" in content
180180

181181
def test_template_dark_mode_uses_body_dark_theme(self):
182182
"""Layout template should target body.dark-theme for dark colors."""

0 commit comments

Comments
 (0)