Skip to content

Commit f2c2dbb

Browse files
committed
Merge branch 'master' into drop-reqs
# Conflicts: # python_docs_theme/__init__.py # python_docs_theme/static/pydoctheme.css
2 parents dbda1e8 + 24ed154 commit f2c2dbb

File tree

6 files changed

+53
-10
lines changed

6 files changed

+53
-10
lines changed

CHANGELOG.rst

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
Changelog
22
=========
33

4+
`2025.2 <https://github.com/python/python-docs-theme/releases/tag/2025.2>`_
5+
---------------------------------------------------------------------------
6+
7+
- Note minimum requirements for Sphinx (#216)
8+
Contributed by Adam Turner
9+
- Horizontally centre the sidebar collapse button (#219)
10+
Contributed by Tomas Roun
11+
- Make sidebar width more flexible (#218)
12+
Contributed by Tomas Roun
13+
- Set ``__version__`` in the runtime package (#222)
14+
Contributed by Adam Turner
15+
416
`2024.12 <https://github.com/python/python-docs-theme/releases/tag/2024.12>`_
517
-----------------------------------------------------------------------------
618

CONTRIBUTING.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ How to release
22
--------------
33

44
- Update ``CHANGELOG.rst``
5-
- Bump version (YYYY.MM) in ``pyproject.toml``
5+
- Bump version (YYYY.MM) in ``python_docs_theme/__init__.py``
66
- Commit
77
- Push to check tests pass on
88
`GitHub Actions <https://github.com/python/python-docs-theme/actions>`__

babel_runner.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import argparse
6+
import ast
67
import subprocess
78
from pathlib import Path
89

@@ -17,6 +18,8 @@
1718
) from ie
1819

1920
PROJECT_DIR = Path(__file__).resolve().parent
21+
PYPROJECT_TOML = PROJECT_DIR / "pyproject.toml"
22+
INIT_PY = PROJECT_DIR / "python_docs_theme" / "__init__.py"
2023

2124
# Global variables used by pybabel below (paths relative to PROJECT_DIR)
2225
DOMAIN = "messages"
@@ -29,9 +32,23 @@
2932

3033
def get_project_info() -> dict:
3134
"""Retrieve project's info to populate the message catalog template"""
32-
with open(Path(PROJECT_DIR / "pyproject.toml"), "rb") as f:
33-
data = tomllib.load(f)
34-
return data["project"]
35+
pyproject_text = PYPROJECT_TOML.read_text(encoding="utf-8")
36+
project_data = tomllib.loads(pyproject_text)["project"]
37+
38+
# read __version__ from __init__.py
39+
for child in ast.parse(INIT_PY.read_bytes()).body:
40+
if not isinstance(child, ast.Assign):
41+
continue
42+
target = child.targets[0]
43+
if not isinstance(target, ast.Name) or target.id != "__version__":
44+
continue
45+
version_node = child.value
46+
if not isinstance(version_node, ast.Constant):
47+
continue
48+
project_data["version"] = version_node.value
49+
break
50+
51+
return project_data
3552

3653

3754
def extract_messages() -> None:

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ requires = [
66

77
[project]
88
name = "python-docs-theme"
9-
version = "2024.12"
109
description = "The Sphinx theme for the CPython docs and related projects"
1110
readme = "README.md"
1211
license.file = "LICENSE"
@@ -27,6 +26,8 @@ classifiers = [
2726
"Topic :: Documentation",
2827
"Topic :: Software Development :: Documentation",
2928
]
29+
dynamic = [ "version" ]
30+
3031
dependencies = [
3132
"sphinx>=7.3",
3233
]

python_docs_theme/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
from __future__ import annotations
22

33
from pathlib import Path
4-
from typing import TYPE_CHECKING
54

5+
TYPE_CHECKING = False
66
if TYPE_CHECKING:
77
from sphinx.application import Sphinx
88
from sphinx.util.typing import ExtensionMetadata
99

10+
__version__ = "2025.2"
11+
1012
THEME_PATH = Path(__file__).resolve().parent
1113

1214

1315
def setup(app: Sphinx) -> ExtensionMetadata:
1416
app.require_sphinx("7.3")
17+
1518
app.add_html_theme("python_docs_theme", THEME_PATH)
1619

1720
return {
18-
"version": "2024.12",
21+
"version": __version__,
1922
"parallel_read_safe": True,
2023
"parallel_write_safe": True,
2124
}

python_docs_theme/static/pydoctheme.css

+13-3
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ span.pre {
138138
}
139139

140140
div.sphinxsidebar {
141+
display: flex;
142+
width: min(25vw, 350px);
141143
float: none;
142144
position: sticky;
143145
top: 0;
@@ -154,13 +156,17 @@ div.sphinxsidebar h4 {
154156
margin-top: 1.5em;
155157
}
156158

159+
div.bodywrapper {
160+
margin-left: min(25vw, 350px);
161+
}
162+
157163
div.sphinxsidebarwrapper {
158-
width: 217px;
159164
box-sizing: border-box;
160165
height: 100%;
161166
overflow-x: hidden;
162167
overflow-y: auto;
163-
float: left;
168+
float: none;
169+
flex-grow: 1;
164170
}
165171

166172
div.sphinxsidebarwrapper > h3:first-child {
@@ -189,7 +195,11 @@ div.sphinxsidebar input[type='text'] {
189195
}
190196

191197
#sidebarbutton {
198+
display: flex;
199+
justify-content: center;
200+
align-items: center;
192201
width: 12px;
202+
min-width: 12px;
193203
border-radius: 0 5px 5px 0;
194204
border-left: none;
195205
}
@@ -470,7 +480,7 @@ div.genindex-jumpbox a {
470480
margin-inline-end: 0;
471481
}
472482
/* Remove sidebar and top related bar */
473-
div.related, .sphinxsidebar {
483+
div.related, div.sphinxsidebar {
474484
display: none;
475485
}
476486
/* Anchorlinks are not hidden by fixed-positioned navbar when scrolled to */

0 commit comments

Comments
 (0)