Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .babel.cfg
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
[javascript: **.js]

[jinja2: **.html]
11 changes: 6 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
strategy:
fail-fast: false
matrix:
branch: ["origin/main", "3.13", "3.12", "3.11", "3.10"]
branch: ["3.14", "3.13", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3
python-version: ${{ matrix.branch }}
allow-prereleases: true
cache: pip
- name: Clone docsbuild scripts
Expand All @@ -37,8 +37,9 @@ jobs:
--group "$(id -g)"
--skip-cache-invalidation
--theme "$(pwd)"
--language en
--branch ${{ matrix.branch }}
--languages en
--branches ${{ matrix.branch }}
${{ matrix.branch == '3.14' && '--select-output no-html' || '' }}
- name: Show logs
if: failure()
run: |
Expand All @@ -56,7 +57,7 @@ jobs:
matrix:
os: ["ubuntu-latest", "windows-latest"]
# Test minimum supported and latest stable from 3.x series
python-version: ["3.10", "3"]
python-version: ["3.12", "3"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ repos:
rev: v2.5.0
hooks:
- id: pyproject-fmt
args: [--max-supported-python=3.13]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.23
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
Changelog
=========

`2025.4.1 <https://github.com/python/python-docs-theme/releases/tag/2025.4.1>`_
-------------------------------------------------------------------------------

* Fix copy button with multiple tracebacks by @tomasr8 in https://github.com/python/python-docs-theme/pull/240

`2025.4 <https://github.com/python/python-docs-theme/releases/tag/2025.4>`_
---------------------------------------------------------------------------

* Require Sphinx 7.3 by @AA-Turner in https://github.com/python/python-docs-theme/pull/221
* Add support for Python 3.14 by @hugovk https://github.com/python/python-docs-theme/pull/236
* Drop support for Python 3.10 and 3.11 by @hugovk in https://github.com/python/python-docs-theme/pull/234
* Add a copy button to code samples by @tomasr8 in https://github.com/python/python-docs-theme/pull/231
* Add missing i18n for copy button titles by @tomasr8 in https://github.com/python/python-docs-theme/pull/225
* Use consistent line-height for light & dark theme by @tomasr8 in https://github.com/python/python-docs-theme/pull/227
* Remove self-closing tags by @hugovk in https://github.com/python/python-docs-theme/pull/226
* Replace deprecated classifier with licence expression (PEP 639) by @hugovk in https://github.com/python/python-docs-theme/pull/237

`2025.2 <https://github.com/python/python-docs-theme/releases/tag/2025.2>`_
---------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Python Docs Sphinx Theme

This is the theme for the Python documentation.
It requires Python 3.10 or newer and Sphinx 7.3 or newer.
It requires Python 3.12 or newer and Sphinx 7.3 or newer.

Note that when adopting this theme, you're also borrowing an element of the
trust and credibility established by the CPython core developers over the
Expand Down
11 changes: 1 addition & 10 deletions babel_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,9 @@
import argparse
import ast
import subprocess
import tomllib
from pathlib import Path

try:
import tomllib
except ImportError:
try:
import tomli as tomllib
except ImportError as ie:
raise ImportError(
"tomli or tomllib is required to parse pyproject.toml"
) from ie

PROJECT_DIR = Path(__file__).resolve().parent
PYPROJECT_TOML = PROJECT_DIR / "pyproject.toml"
INIT_PY = PROJECT_DIR / "python_docs_theme" / "__init__.py"
Expand Down
12 changes: 7 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ requires = [
name = "python-docs-theme"
description = "The Sphinx theme for the CPython docs and related projects"
readme = "README.md"
license.file = "LICENSE"
license = "PSF-2.0"
license-files = [ "LICENSE" ]
authors = [ { name = "PyPA", email = "[email protected]" } ]
requires-python = ">=3.10"
requires-python = ">=3.12"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Framework :: Sphinx :: Theme",
"Intended Audience :: Developers",
"License :: OSI Approved :: Python Software Foundation License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Documentation",
"Topic :: Software Development :: Documentation",
]
Expand Down Expand Up @@ -69,3 +68,6 @@ lint.ignore = [
"E241", # Multiple spaces after ','
]
lint.isort.required-imports = [ "from __future__ import annotations" ]

[tool.pyproject-fmt]
max_supported_python = "3.14"
14 changes: 13 additions & 1 deletion python_docs_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,32 @@

from pathlib import Path

import gettext

TYPE_CHECKING = False
if TYPE_CHECKING:
from sphinx.application import Sphinx
from sphinx.util.typing import ExtensionMetadata

__version__ = "2025.2"
__version__ = "2025.4.1"

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


def _setup_translations(app):
language = app.config.language or 'en'
try:
translation = gettext.translation(domain="messages", localedir=str(THEME_PATH / "locales"), languages=[language])
app.builder.templates.environment.install_gettext_translations(translation, newstyle=True)
except FileNotFoundError:
app.builder.templates.environment.install_gettext(lambda x: x, newstyle=True)


def setup(app: Sphinx) -> ExtensionMetadata:
app.require_sphinx("7.3")

app.add_html_theme("python_docs_theme", str(THEME_PATH))
app.connect("builder-inited", _setup_translations)

return {
"version": __version__,
Expand Down
2 changes: 1 addition & 1 deletion python_docs_theme/footerdonate.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% trans %}The Python Software Foundation is a non-profit corporation.{% endtrans %}
<a href="https://www.python.org/psf/donations/">{% trans %}Please donate.{% endtrans %}</a>
<br />
<br>
34 changes: 17 additions & 17 deletions python_docs_theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h3>{{ _('Navigation') }}</h3>
</li>
{%- endfor %}
{%- block rootrellink %}
<li><img src="{{ pathto('_static/' ~ theme_root_icon, 1) }}" alt="{{ theme_root_icon_alt_text }}" style="vertical-align: middle; margin-top: -1px"/></li>
<li><img src="{{ pathto('_static/' ~ theme_root_icon, 1) }}" alt="{{ theme_root_icon_alt_text }}" style="vertical-align: middle; margin-top: -1px"></li>
<li><a href="{{theme_root_url}}">{{theme_root_name}}</a>{{ reldelim1 }}</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
Expand Down Expand Up @@ -48,8 +48,8 @@ <h3>{{ _('Navigation') }}</h3>
{%- if builder != "htmlhelp" %}
<div class="inline-search" role="search">
<form class="inline-search" action="{{ pathto('search') }}" method="get">
<input placeholder="{{ _('Quick search') }}" aria-label="{{ _('Quick search') }}" type="search" name="q" id="search-box" />
<input type="submit" value="{{ _('Go') }}" />
<input placeholder="{{ _('Quick search') }}" aria-label="{{ _('Quick search') }}" type="search" name="q" id="search-box">
<input type="submit" value="{{ _('Go') }}">
</form>
</div>
{%- endif %}
Expand All @@ -71,7 +71,7 @@ <h3>{{ _('Navigation') }}</h3>

{%- block extrahead -%}
<link rel="stylesheet" href="{{ pathto('_static/pydoctheme_dark.css', 1) }}" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
<link rel="shortcut icon" type="image/png" href="{{ pathto('_static/' ~ theme_root_icon, 1) }}" />
<link rel="shortcut icon" type="image/png" href="{{ pathto('_static/' ~ theme_root_icon, 1) }}">
{%- if builder != "htmlhelp" %}
{%- if not embedded %}
<script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script>
Expand All @@ -93,23 +93,23 @@ <h3>{{ _('Navigation') }}</h3>
{%- if builder != 'htmlhelp' %}
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="{{ _('Menu')}}" />
aria-pressed="false" aria-expanded="false" role="button" aria-label="{{ _('Menu')}}">
<nav class="nav-content" role="navigation">
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<span class="nav-items-wrapper">
<a href="{{ theme_root_url }}" class="nav-logo">
<img src="{{ pathto('_static/' ~ theme_root_icon, 1) }}" alt="{{ theme_root_icon_alt_text }}"/>
<img src="{{ pathto('_static/' ~ theme_root_icon, 1) }}" alt="{{ theme_root_icon_alt_text }}">
</a>
<span class="version_switcher_placeholder"></span>
{%- if pagename != "search" and builder != "singlehtml" %}
<form role="search" class="search" action="{{ pathto('search') }}" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
</svg>
<input placeholder="{{ _('Quick search') }}" aria-label="{{ _('Quick search') }}" type="search" name="q" />
<input type="submit" value="{{ _('Go') }}"/>
<input placeholder="{{ _('Quick search') }}" aria-label="{{ _('Quick search') }}" type="search" name="q">
<input type="submit" value="{{ _('Go') }}">
</form>
{%- endif %}
</span>
Expand All @@ -121,7 +121,7 @@ <h3>{{ _('Navigation') }}</h3>
{%- if logo %}
<p class="logo">
<a href="{{ pathto('index') }}">
<img class="logo" src="{{ pathto('_static/' ~ logo, 1)|e }}" alt="Logo"/>
<img class="logo" src="{{ pathto('_static/' ~ logo, 1)|e }}" alt="Logo">
</a>
</p>
{%- endif %}
Expand All @@ -143,29 +143,29 @@ <h3>{{ _('Navigation') }}</h3>
{% if theme_copyright_url or hasdoc('copyright') %}
</a>
{% endif %} {{ copyright|e }}.
<br />
<br>
{% trans %}This page is licensed under the Python Software Foundation License Version 2.{% endtrans %}
<br />
<br>
{% trans %}Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.{% endtrans %}
<br />
<br>
{% if theme_license_url %}
{% trans license_file=theme_license_url %}See <a href="{{ license_file }}">History and License</a> for more information.{% endtrans %}<br />
{% trans license_file=theme_license_url %}See <a href="{{ license_file }}">History and License</a> for more information.{% endtrans %}<br>
{% endif %}
{% if theme_hosted_on %}
{% trans hosted_on=theme_hosted_on %}Hosted on {{ hosted_on }}.{% endtrans %}<br />
{% trans hosted_on=theme_hosted_on %}Hosted on {{ hosted_on }}.{% endtrans %}<br>
{% endif %}
<br />
<br>

{% include "footerdonate.html" %}
<br />
<br>

{%- if last_updated %}
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
{%- endif %}
{% if theme_issues_url %}
{% trans %}<a href="{{ theme_issues_url }}">Found a bug</a>?{% endtrans %}
{% endif %}
<br />
<br>

{% trans sphinx_version=sphinx_version|e %}Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}
</div>
Expand Down
Loading