File tree 6 files changed +53
-10
lines changed
6 files changed +53
-10
lines changed Original file line number Diff line number Diff line change 1
1
Changelog
2
2
=========
3
3
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
+
4
16
`2024.12 <https://github.com/python/python-docs-theme/releases/tag/2024.12 >`_
5
17
-----------------------------------------------------------------------------
6
18
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ How to release
2
2
--------------
3
3
4
4
- Update ``CHANGELOG.rst ``
5
- - Bump version (YYYY.MM) in ``pyproject.toml ``
5
+ - Bump version (YYYY.MM) in ``python_docs_theme/__init__.py ``
6
6
- Commit
7
7
- Push to check tests pass on
8
8
`GitHub Actions <https://github.com/python/python-docs-theme/actions >`__
Original file line number Diff line number Diff line change 3
3
from __future__ import annotations
4
4
5
5
import argparse
6
+ import ast
6
7
import subprocess
7
8
from pathlib import Path
8
9
17
18
) from ie
18
19
19
20
PROJECT_DIR = Path (__file__ ).resolve ().parent
21
+ PYPROJECT_TOML = PROJECT_DIR / "pyproject.toml"
22
+ INIT_PY = PROJECT_DIR / "python_docs_theme" / "__init__.py"
20
23
21
24
# Global variables used by pybabel below (paths relative to PROJECT_DIR)
22
25
DOMAIN = "messages"
29
32
30
33
def get_project_info () -> dict :
31
34
"""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
35
52
36
53
37
54
def extract_messages () -> None :
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ requires = [
6
6
7
7
[project ]
8
8
name = " python-docs-theme"
9
- version = " 2024.12"
10
9
description = " The Sphinx theme for the CPython docs and related projects"
11
10
readme = " README.md"
12
11
license.file = " LICENSE"
@@ -27,6 +26,8 @@ classifiers = [
27
26
" Topic :: Documentation" ,
28
27
" Topic :: Software Development :: Documentation" ,
29
28
]
29
+ dynamic = [ " version" ]
30
+
30
31
dependencies = [
31
32
" sphinx>=7.3" ,
32
33
]
Original file line number Diff line number Diff line change 1
1
from __future__ import annotations
2
2
3
3
from pathlib import Path
4
- from typing import TYPE_CHECKING
5
4
5
+ TYPE_CHECKING = False
6
6
if TYPE_CHECKING :
7
7
from sphinx .application import Sphinx
8
8
from sphinx .util .typing import ExtensionMetadata
9
9
10
+ __version__ = "2025.2"
11
+
10
12
THEME_PATH = Path (__file__ ).resolve ().parent
11
13
12
14
13
15
def setup (app : Sphinx ) -> ExtensionMetadata :
14
16
app .require_sphinx ("7.3" )
17
+
15
18
app .add_html_theme ("python_docs_theme" , THEME_PATH )
16
19
17
20
return {
18
- "version" : "2024.12" ,
21
+ "version" : __version__ ,
19
22
"parallel_read_safe" : True ,
20
23
"parallel_write_safe" : True ,
21
24
}
Original file line number Diff line number Diff line change @@ -138,6 +138,8 @@ span.pre {
138
138
}
139
139
140
140
div .sphinxsidebar {
141
+ display : flex;
142
+ width : min (25vw , 350px );
141
143
float : none;
142
144
position : sticky;
143
145
top : 0 ;
@@ -154,13 +156,17 @@ div.sphinxsidebar h4 {
154
156
margin-top : 1.5em ;
155
157
}
156
158
159
+ div .bodywrapper {
160
+ margin-left : min (25vw , 350px );
161
+ }
162
+
157
163
div .sphinxsidebarwrapper {
158
- width : 217px ;
159
164
box-sizing : border-box;
160
165
height : 100% ;
161
166
overflow-x : hidden;
162
167
overflow-y : auto;
163
- float : left;
168
+ float : none;
169
+ flex-grow : 1 ;
164
170
}
165
171
166
172
div .sphinxsidebarwrapper > h3 : first-child {
@@ -189,7 +195,11 @@ div.sphinxsidebar input[type='text'] {
189
195
}
190
196
191
197
# sidebarbutton {
198
+ display : flex;
199
+ justify-content : center;
200
+ align-items : center;
192
201
width : 12px ;
202
+ min-width : 12px ;
193
203
border-radius : 0 5px 5px 0 ;
194
204
border-left : none;
195
205
}
@@ -470,7 +480,7 @@ div.genindex-jumpbox a {
470
480
margin-inline-end : 0 ;
471
481
}
472
482
/* Remove sidebar and top related bar */
473
- div .related , .sphinxsidebar {
483
+ div .related , div .sphinxsidebar {
474
484
display : none;
475
485
}
476
486
/* Anchorlinks are not hidden by fixed-positioned navbar when scrolled to */
You can’t perform that action at this time.
0 commit comments