Skip to content

Commit 7c199fa

Browse files
committed
Require Sphinx 7.2+
1 parent 1d36ee8 commit 7c199fa

File tree

5 files changed

+3
-163
lines changed

5 files changed

+3
-163
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Python Docs Sphinx Theme
22

33
This is the theme for the Python documentation.
4-
It requires Python 3.10 or newer and Sphinx 3.4 or newer.
4+
It requires Python 3.10 or newer and Sphinx 7.2 or newer.
55

66
Note that when adopting this theme, you're also borrowing an element of the
77
trust and credibility established by the CPython core developers over the

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ classifiers = [
2828
"Topic :: Software Development :: Documentation",
2929
]
3030
dependencies = [
31-
"sphinx>=3.4",
31+
"sphinx>=7.2",
3232
]
3333

3434
urls.Code = "https://github.com/python/python-docs-theme"

python_docs_theme/__init__.py

+1-49
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,17 @@
11
from __future__ import annotations
22

3-
import hashlib
43
import os
5-
from functools import cache
64
from pathlib import Path
7-
from typing import Any
8-
9-
import sphinx.application
10-
from sphinx.builders.html import StandaloneHTMLBuilder
115

126
THEME_PATH = Path(__file__).parent.resolve()
137

148

15-
@cache
16-
def _asset_hash(path: str) -> str:
17-
"""Append a `?digest=` to an url based on the file content."""
18-
full_path = THEME_PATH / path.replace("_static/", "static/")
19-
digest = hashlib.sha1(full_path.read_bytes()).hexdigest()
20-
21-
return f"{path}?digest={digest}"
22-
23-
24-
def _add_asset_hashes(static: list[str], add_digest_to: list[str]) -> None:
25-
for asset in add_digest_to:
26-
index = static.index(asset)
27-
static[index].filename = _asset_hash(asset) # type: ignore[attr-defined]
28-
29-
30-
def _html_page_context(
31-
app: sphinx.application.Sphinx,
32-
pagename: str,
33-
templatename: str,
34-
context: dict[str, Any],
35-
doctree: Any,
36-
) -> None:
37-
if app.config.html_theme != "python_docs_theme":
38-
return
39-
40-
assert isinstance(app.builder, StandaloneHTMLBuilder)
41-
42-
if (4,) <= sphinx.version_info < (7, 1) and "css_files" in context:
43-
if "_static/pydoctheme.css" not in context["css_files"]:
44-
raise ValueError(
45-
"This documentation is not using `pydoctheme.css` as the stylesheet. "
46-
"If you have set `html_style` in your conf.py file, remove it."
47-
)
48-
49-
_add_asset_hashes(
50-
context["css_files"],
51-
["_static/pydoctheme.css"],
52-
)
53-
54-
559
def setup(app):
56-
app.require_sphinx("3.4")
10+
app.require_sphinx("7.2")
5711

5812
current_dir = os.path.abspath(os.path.dirname(__file__))
5913
app.add_html_theme("python_docs_theme", current_dir)
6014

61-
app.connect("html-page-context", _html_page_context)
62-
6315
return {
6416
"version": "2024.12",
6517
"parallel_read_safe": True,

python_docs_theme/static/pydoctheme.css

-17
Original file line numberDiff line numberDiff line change
@@ -191,28 +191,11 @@ div.sphinxsidebar input[type='text'] {
191191
}
192192

193193
#sidebarbutton {
194-
/* Sphinx 4.x and earlier compat */
195-
height: 100%;
196-
background-color: #CCCCCC;
197-
margin-left: 0;
198-
color: #444444;
199-
font-size: 1.2em;
200-
cursor: pointer;
201-
padding-top: 1px;
202-
float: right;
203-
display: table;
204-
/* after Sphinx 4.x and earlier is dropped, only the below is needed */
205194
width: 12px;
206195
border-radius: 0 5px 5px 0;
207196
border-left: none;
208197
}
209198

210-
#sidebarbutton span {
211-
/* Sphinx 4.x and earlier compat */
212-
display: table-cell;
213-
vertical-align: middle;
214-
}
215-
216199
#sidebarbutton:hover {
217200
background-color: #AAAAAA;
218201
}

python_docs_theme/static/sidebar.js_t

-95
This file was deleted.

0 commit comments

Comments
 (0)