File tree Expand file tree Collapse file tree 6 files changed +53
-10
lines changed
Expand file tree Collapse file tree 6 files changed +53
-10
lines changed Original file line number Diff line number Diff line change 11Changelog
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
Original file line number Diff line number Diff 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 >`__
Original file line number Diff line number Diff line change 33from __future__ import annotations
44
55import argparse
6+ import ast
67import subprocess
78from pathlib import Path
89
1718 ) from ie
1819
1920PROJECT_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)
2225DOMAIN = "messages"
2932
3033def 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
3754def extract_messages () -> None :
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ requires = [
66
77[project ]
88name = " python-docs-theme"
9- version = " 2024.12"
109description = " The Sphinx theme for the CPython docs and related projects"
1110readme = " README.md"
1211license.file = " LICENSE"
@@ -27,6 +26,8 @@ classifiers = [
2726 " Topic :: Documentation" ,
2827 " Topic :: Software Development :: Documentation" ,
2928]
29+ dynamic = [ " version" ]
30+
3031dependencies = [
3132 " sphinx>=7.3" ,
3233]
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33from pathlib import Path
4- from typing import TYPE_CHECKING
54
5+ TYPE_CHECKING = False
66if TYPE_CHECKING :
77 from sphinx .application import Sphinx
88 from sphinx .util .typing import ExtensionMetadata
99
10+ __version__ = "2025.2"
11+
1012THEME_PATH = Path (__file__ ).resolve ().parent
1113
1214
1315def 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 }
Original file line number Diff line number Diff line change @@ -138,6 +138,8 @@ span.pre {
138138}
139139
140140div .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+
157163div .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
166172div .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 */
You can’t perform that action at this time.
0 commit comments