Skip to content

Commit 33e3a16

Browse files
authored
Merge branch 'master' into MAINT_switch_prettier_fork
2 parents 8fd0498 + f53a040 commit 33e3a16

36 files changed

+517
-143
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/components/source-files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Once this is provided, you may add source buttons by following the following sec
4848
(source-buttons:source)=
4949
## Add a button to the page source
5050

51-
Show the raw source of the page on the provider you've proivded.
51+
Show the raw source of the page on the provider you've provided.
5252
To add a button to the page source, first [configure your source repository](source-buttons:repository) and then add:
5353

5454
```python

docs/content/launch.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
# Launch buttons for interactivity
33

44
You can automatically add buttons that allow users to interact with your
5-
book's content. This is either by directing them to a BinderHub or JupyterHub
6-
that runs in the cloud, or by making your page interactive using Thebe.
5+
book's content. This is can be by directing them to
6+
a [JupyterLite](https://jupyterlite.readthedocs.io) installation (that runs in
7+
the user's browser) or one of BinderHub or JupyterHub (that runs in the
8+
cloud), or by making your page interactive using Thebe.
79

8-
To use either Binder or JupyterHub links, you'll first need to configure your
9-
documentation's repository url:
10+
To use any of JupyterLite or Binder or JupyterHub links, you'll first need to
11+
configure your documentation's repository url:
1012

1113
```python
1214
html_theme_options = {
@@ -26,6 +28,28 @@ folder as your content, then Binder/JupyterHub links will point to the ipynb
2628
file instead of the text file.
2729
```
2830

31+
## JupyterLite
32+
33+
If you are adding [JupyterLite](https://github.com/jupyterlite/jupyterlite) links to your page, first work out where your
34+
JupyterLite instance will be serving from, then add the URL to your
35+
configuration. In the example below, we've set up JupyterLite pages at the
36+
base URL of the main pages site, and at subdirectory `interact/lab`:
37+
38+
```python
39+
html_theme_options = {
40+
...
41+
"launch_buttons": {
42+
"jupyterlite_url": "interact/lab/index.html"
43+
},
44+
...
45+
}
46+
```
47+
48+
See <https://odsti.github.io/cfd-textbook> for an example
49+
[JupyterBook](https://jupyterbook.org) project serving JupyterLite using this
50+
configuration, and <https://github.com/odsti/cfd-textbook> for the driving
51+
repository.
52+
2953
## Binder / BinderHub
3054

3155
To add Binder links to your page, add the following configuration:

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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ filterwarnings = [
2525
# Sphinx triggers this
2626
'''ignore:'imghdr' is deprecated and slated for removal in Python 3\.13:DeprecationWarning''',
2727
'''ignore:'sphinx.util.import_object' is deprecated.:PendingDeprecationWarning''',
28-
'ignore:Parsing dates involving a day of month without a year specified is ambiguious:DeprecationWarning'
28+
'ignore:Parsing dates involving a day of month without a year specified is ambiguious:DeprecationWarning',
29+
'ignore:Argument "parser_name" will be removed in Docutils 2.0.:PendingDeprecationWarning',
2930
]
3031

3132
[project]
@@ -37,7 +38,7 @@ readme = "README.md"
3738
requires-python = ">=3.9"
3839
dependencies = [
3940
"sphinx>=6.1",
40-
"pydata-sphinx-theme==0.15.4"
41+
"pydata-sphinx-theme==0.16.1"
4142
]
4243

4344
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+
}

0 commit comments

Comments
 (0)