Skip to content

Commit 79b19ae

Browse files
authored
Update to latest pydata and python releases (#920)
1 parent c33f047 commit 79b19ae

29 files changed

+442
-133
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,16 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
os: [ubuntu-latest]
31-
python-version: ["3.10", "3.11", "3.12.*", "3.13"]
32-
# Only test the latest major release of Sphinx because otherwise we need to
33-
# keep multiple versions of regression tests on file and this creates lots of
34-
# noise in the tests.
35-
sphinx: ["~=6.0","~=7.0", "~=8.0"]
31+
python-version: ["3.11", "3.12", "3.13"]
32+
# Test last 2 major releases of Sphinx; regression fixtures target the latest.
33+
sphinx: ["~=7.0", "~=8.0"]
3634
include:
3735
- os: windows-latest
38-
# Python 3.12 is broken on windows builds until the following PR is released:
39-
# https://github.com/pradyunsg/sphinx-theme-builder/pull/47
40-
python-version: 3.11
36+
python-version: 3.13
4137
# Windows pulling in dependencies fails
4238
experimental: true
4339
- os: macos-latest
4440
python-version: 3.x
45-
# Sphinx <8 is 3.9+
46-
- os: ubuntu-latest
47-
python-version: "3.9"
48-
sphinx: "~=7.0"
49-
- os: ubuntu-latest
50-
python-version: "3.9"
51-
sphinx: "~=6.0"
5241

5342
runs-on: ${{ matrix.os }}
5443

@@ -73,10 +62,10 @@ jobs:
7362
# Only upload to codecov on pull requests so that we don't trigger rate limit blocks
7463
# Disabled for now with false &&
7564
- name: Upload to Codecov
76-
if: false && matrix.os == 'ubuntu-latest' && matrix.python-version == 3.9 && matrix.sphinx == '~=7.0' && github.repository == 'executablebooks/sphinx-book-theme' && github.event_name == 'pull_request'
65+
if: false && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' && matrix.sphinx == '~=8.0' && github.repository == 'executablebooks/sphinx-book-theme' && github.event_name == 'pull_request'
7766
uses: codecov/[email protected]
7867
with:
79-
name: ebp-sbt-pytests-py3.7
68+
name: ebp-sbt-pytests-py3.11
8069
flags: pytests
8170
file: ./coverage.xml
8271
fail_ci_if_error: true
@@ -90,7 +79,7 @@ jobs:
9079
- name: Set up Python
9180
uses: actions/setup-python@v5
9281
with:
93-
python-version: '3.9'
82+
python-version: '3.13'
9483
cache: "pip"
9584
cache-dependency-path: "pyproject.toml"
9685
- name: Install fonts

ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a short overview of the general architecture and structure of the repository, to help you orient yourself.
44

5-
This theme uses [sphinx-theme-builder](https://sphinx-theme-builder.readthedocs.io/en/latest/) as its build backend, and follows the [filesystem layout](https://sphinx-theme-builder.readthedocs.io/en/latest/filesystem-layout/) recommended by it.
5+
This theme uses [sphinx-theme-builder](https://sphinx-theme-builder.readthedocs.io/en/latest/) as its build backend, and follows the [filesystem layout](https://sphinx-theme-builder.readthedocs.io/en/latest/filesystem-layout.html) recommended by it.
66
See below for some more specific sections
77

88
```{contents}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
[![codecov][codecov-badge]][codecov-link] [![Documentation Status][rtd-badge]][rtd-link] [![PyPI][pypi-badge]][pypi-link]
44

5+
> [!NOTE]
6+
> **Maintenance Mode**: This project is currently in maintenance mode. We are accepting bug fixes as best we can, but there are not dedicated resources to review and merge. New feature development is not likely. If you're interested in becoming a maintainer and helping keep this project actively developed, please reach out by opening an issue!
7+
58
**An interactive book theme for Sphinx**.
69

710
This is a lightweight Sphinx theme designed to mimic the look-and-feel of an

docs/contributing/tests.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ $ tox
1414
You can specify a specific environment like so:
1515

1616
```console
17-
# Run the tests with Python 3.9, Sphinx 4
18-
$ tox -e py39-sphinx4
17+
# Run the tests with Python 3.10, Sphinx 6
18+
$ tox -e py310-sphinx6
1919
```
2020

2121
## List all test environments
@@ -46,7 +46,7 @@ By default, `tox` will only install the necessary environment **once**.
4646
If you'd like to force a re-build, use the `-r` parameter. For example:
4747

4848
```console
49-
$ tox -r -e py38-sphinx3
49+
$ tox -r -e py310-sphinx6
5050
```
5151

5252
## Test audits with lighthouse
@@ -63,8 +63,8 @@ To preview the output of these tests:
6363

6464
## Test multiple Sphinx versions
6565

66-
This theme is tested against the latest two major versions of Sphinx.
67-
We try to set up our regression tests such that there are no differences between these two Sphinx versions.
66+
This theme is tested against Sphinx 6-9.
67+
We try to set up our regression tests such that there are no differences between these Sphinx versions.
6868

6969
### Unit tests
7070

@@ -73,9 +73,9 @@ Use the variable `sphinx_build.software_versions` to conditionally run tests bas
7373
For example:
7474

7575
```python
76-
if sphinx_build.software_versions == ".sphinx3":
76+
if sphinx_build.software_versions == ".sphinx8":
7777
foo
78-
elif sphinx_build.software_versions == ".sphinx4":
78+
elif sphinx_build.software_versions == ".sphinx9":
7979
bar
8080
```
8181

docs/reference/extensions.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,25 @@ This toggle is in the margin!
108108

109109
## `sphinx-design` for UI components
110110

111+
[`sphinx-design`](https://sphinx-design.readthedocs.io/) provides various UI components like badges, cards, and dropdowns.
112+
113+
**Badge:**
114+
111115
{bdg-primary}`Test badge`.
116+
117+
**Card:**
118+
119+
::::{card} Card Title
120+
:class-card: sd-border-0
121+
Card header.
122+
^^^
123+
Card content goes here. This demonstrates how cards look in both light and dark modes.
124+
+++
125+
Card footer.
126+
::::
127+
128+
**Dropdown:**
129+
130+
:::{dropdown} Click to expand
131+
This is the dropdown content. It should be readable in both light and dark modes.
132+
:::

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ readme = "README.md"
3737
requires-python = ">=3.9"
3838
dependencies = [
3939
"sphinx>=6.1",
40-
"pydata-sphinx-theme==0.15.4"
40+
"pydata-sphinx-theme==0.16.1"
4141
]
4242

4343
license = { file = "LICENSE" }

src/sphinx_book_theme/assets/scripts/index.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,70 @@ function addNoPrint() {
181181
window.initThebeSBT = initThebeSBT;
182182
window.toggleFullScreen = toggleFullScreen;
183183

184+
/**
185+
* Add blur behavior to buttons with tooltips
186+
* This prevents tooltips from persisting after clicking buttons
187+
*/
188+
function addBlurToButtons() {
189+
// List of button selectors that should blur on click to dismiss tooltips
190+
const buttonSelectors = [
191+
".theme-switch-button",
192+
".search-button",
193+
".primary-toggle",
194+
".secondary-toggle",
195+
];
196+
197+
// Add blur on click for each button type
198+
buttonSelectors.forEach((selector) => {
199+
const button = document.querySelector(selector);
200+
if (button) {
201+
button.addEventListener(
202+
"click",
203+
() => {
204+
button.blur();
205+
},
206+
true,
207+
);
208+
}
209+
});
210+
}
211+
212+
/**
213+
* Fix sidebar toggle behavior for wide screens
214+
* On wide screens (>= 992px), clicking the toggle should collapse the sidebar,
215+
* not open it as a dialog modal. The dialog behavior is only for narrow screens.
216+
*/
217+
function fixSidebarToggle() {
218+
const primaryToggle = document.querySelector(".primary-toggle");
219+
const primarySidebar = document.querySelector("#pst-primary-sidebar");
220+
const primaryDialog = document.querySelector("#pst-primary-sidebar-modal");
221+
222+
// Fix primary sidebar toggle
223+
if (primaryToggle && primarySidebar && primaryDialog) {
224+
// Intercept clicks on the toggle button BEFORE pydata-sphinx-theme's handler
225+
primaryToggle.addEventListener(
226+
"click",
227+
(event) => {
228+
const isWideScreen = window.matchMedia("(min-width: 992px)").matches;
229+
230+
if (isWideScreen) {
231+
// On wide screens, prevent the dialog from opening and toggle sidebar visibility instead
232+
event.preventDefault();
233+
event.stopImmediatePropagation();
234+
235+
// Toggle a class to hide/show the sidebar
236+
primarySidebar.classList.toggle("pst-sidebar-hidden");
237+
}
238+
},
239+
true,
240+
); // Use capture phase to run before PST's handler
241+
}
242+
}
243+
184244
/**
185245
* Set up functions to load when the DOM is ready
186246
*/
187247
sbRunWhenDOMLoaded(initTocHide);
188248
sbRunWhenDOMLoaded(addNoPrint);
249+
sbRunWhenDOMLoaded(addBlurToButtons);
250+
sbRunWhenDOMLoaded(fixSidebarToggle);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Standard Sphinx admonitions
3+
* Improves contrast and readability in dark mode
4+
* Fixes: https://github.com/executablebooks/sphinx-book-theme/issues/743
5+
*/
6+
7+
// Ensure admonition titles have proper contrast in dark mode
8+
html[data-theme="dark"] {
9+
.admonition {
10+
.admonition-title {
11+
// Ensure text is always readable by using a color that contrasts well
12+
// with the admonition background colors
13+
color: var(--pst-color-text-base);
14+
15+
// Add a slight text shadow for better readability on colored backgrounds
16+
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
17+
}
18+
}
19+
}
20+
21+
// Light mode improvements for consistency
22+
html[data-theme="light"] {
23+
.admonition {
24+
.admonition-title {
25+
// Ensure consistent text rendering
26+
color: var(--pst-color-text-base);
27+
}
28+
}
29+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* MyST-NB extension
3+
* Improves contrast and readability in dark mode
4+
* Fixes: https://github.com/executablebooks/sphinx-book-theme/issues/743
5+
*/
6+
7+
// Ensure hide-input tags have proper contrast in dark mode
8+
html[data-theme="dark"] {
9+
.tag_hide_input .cell_input {
10+
summary {
11+
color: var(--pst-color-link);
12+
13+
&:hover {
14+
color: var(--pst-color-link-hover);
15+
}
16+
}
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* sphinx-design extension
3+
* Improves contrast and readability in dark mode
4+
* Fixes: https://github.com/executablebooks/sphinx-book-theme/issues/743
5+
*/
6+
7+
// Ensure sphinx-design cards and dropdowns have proper contrast in dark mode
8+
html[data-theme="dark"] {
9+
.sd-card,
10+
.sd-dropdown {
11+
.sd-card-header,
12+
.sd-card-title,
13+
.sd-summary-title {
14+
color: var(--pst-color-text-base);
15+
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)