Skip to content

Commit f5d080f

Browse files
authored
Require Python 3.10 and Sphinx 7.3 (#221)
1 parent 24ed154 commit f5d080f

File tree

8 files changed

+44
-199
lines changed

8 files changed

+44
-199
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
matrix:
5757
os: ["ubuntu-latest", "windows-latest"]
5858
# Test minimum supported and latest stable from 3.x series
59-
python-version: ["3.9", "3"]
59+
python-version: ["3.10", "3"]
6060
steps:
6161
- uses: actions/checkout@v4
6262
- uses: actions/setup-python@v5

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.9 or newer and Sphinx 3.4 or newer.
4+
It requires Python 3.10 or newer and Sphinx 7.3 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

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description = "The Sphinx theme for the CPython docs and related projects"
1010
readme = "README.md"
1111
license.file = "LICENSE"
1212
authors = [ { name = "PyPA", email = "[email protected]" } ]
13-
requires-python = ">=3.9"
13+
requires-python = ">=3.10"
1414
classifiers = [
1515
"Development Status :: 5 - Production/Stable",
1616
"Framework :: Sphinx :: Theme",
@@ -19,7 +19,6 @@ classifiers = [
1919
"Operating System :: OS Independent",
2020
"Programming Language :: Python",
2121
"Programming Language :: Python :: 3 :: Only",
22-
"Programming Language :: Python :: 3.9",
2322
"Programming Language :: Python :: 3.10",
2423
"Programming Language :: Python :: 3.11",
2524
"Programming Language :: Python :: 3.12",
@@ -30,7 +29,7 @@ classifiers = [
3029
dynamic = [ "version" ]
3130

3231
dependencies = [
33-
"sphinx>=3.4",
32+
"sphinx>=7.3",
3433
]
3534

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

python_docs_theme/__init__.py

+1-50
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
from __future__ import annotations
22

3-
import hashlib
4-
from functools import cache
53
from pathlib import Path
64

7-
import sphinx.application
8-
from sphinx.builders.html import StandaloneHTMLBuilder
9-
105
TYPE_CHECKING = False
116
if TYPE_CHECKING:
12-
from typing import Any
13-
147
from sphinx.application import Sphinx
158
from sphinx.util.typing import ExtensionMetadata
169

@@ -19,53 +12,11 @@
1912
THEME_PATH = Path(__file__).resolve().parent
2013

2114

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

6518
app.add_html_theme("python_docs_theme", str(THEME_PATH))
6619

67-
app.connect("html-page-context", _html_page_context)
68-
6920
return {
7021
"version": __version__,
7122
"parallel_read_safe": True,

python_docs_theme/static/pydoctheme.css

-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@import url('classic.css');
2-
31
/* Common colours */
42
:root {
53
--good-color: rgb(41 100 51);
@@ -200,16 +198,6 @@ div.sphinxsidebar input[type='text'] {
200198
display: flex;
201199
justify-content: center;
202200
align-items: center;
203-
/* Sphinx 4.x and earlier compat */
204-
height: 100%;
205-
background-color: #CCCCCC;
206-
margin-left: 0;
207-
color: #444444;
208-
font-size: 1.2em;
209-
cursor: pointer;
210-
padding-top: 1px;
211-
float: none;
212-
/* after Sphinx 4.x and earlier is dropped, only the below is needed */
213201
width: 12px;
214202
min-width: 12px;
215203
border-radius: 0 5px 5px 0;

python_docs_theme/static/sidebar.js_t

-95
This file was deleted.

python_docs_theme/theme.conf

-37
This file was deleted.

python_docs_theme/theme.toml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[theme]
2+
inherit = "default"
3+
stylesheets = [
4+
"classic.css",
5+
"pydoctheme.css",
6+
]
7+
pygments_style = { default = "default", dark = "monokai" }
8+
9+
[options]
10+
bodyfont = "-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif"
11+
headfont = "-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif"
12+
footerbgcolor = "white"
13+
footertextcolor = "#555555"
14+
relbarbgcolor = "white"
15+
relbartextcolor = "#666666"
16+
relbarlinkcolor = "#444444"
17+
sidebarbgcolor = "white"
18+
sidebartextcolor = "#444444"
19+
sidebarlinkcolor = "#444444"
20+
sidebarbtncolor = "#cccccc"
21+
bgcolor = "white"
22+
textcolor = "#222222"
23+
linkcolor = "#0090c0"
24+
visitedlinkcolor = "#00608f"
25+
headtextcolor = "#1a1a1a"
26+
headbgcolor = "white"
27+
headlinkcolor = "#aaaaaa"
28+
codebgcolor = "#eeffcc"
29+
codetextcolor = "#333333"
30+
31+
hosted_on = ""
32+
issues_url = ""
33+
license_url = ""
34+
root_name = "Python"
35+
root_url = "https://www.python.org/"
36+
root_icon = "py.svg"
37+
root_icon_alt_text = "Python logo"
38+
root_include_title = "True"
39+
copyright_url = ""

0 commit comments

Comments
 (0)