From 946100a6581453dfe9f3830c2495f89338908436 Mon Sep 17 00:00:00 2001 From: joyboy Date: Sun, 23 Aug 2026 17:17:08 +0800 Subject: [PATCH] Import basic.css in the agogo, epub, nonav, scrolls, and traditional themes --- CHANGES.rst | 7 +++++ sphinx/themes/agogo/static/agogo.css.jinja | 2 ++ sphinx/themes/epub/static/epub.css.jinja | 2 ++ sphinx/themes/nonav/static/nonav.css.jinja | 2 ++ .../themes/scrolls/static/scrolls.css.jinja | 2 ++ .../traditional/static/traditional.css.jinja | 2 ++ tests/test_theming/test_theming.py | 28 +++++++++++++++++++ 7 files changed, 45 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index ad6d698341a..f838414abdf 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,13 @@ Release 9.1.1 (in development) ============================== +Features added +-------------- + +* #9093: Import ``basic.css`` in the ``agogo``, ``epub``, ``nonav``, + ``scrolls``, and ``traditional`` themes. + Patch by joyboy + Bugs fixed ---------- diff --git a/sphinx/themes/agogo/static/agogo.css.jinja b/sphinx/themes/agogo/static/agogo.css.jinja index d281c744d3c..fcc2dcf7eb7 100644 --- a/sphinx/themes/agogo/static/agogo.css.jinja +++ b/sphinx/themes/agogo/static/agogo.css.jinja @@ -2,6 +2,8 @@ * Sphinx stylesheet -- agogo theme. */ +@import url("basic.css"); + * { margin: 0px; padding: 0px; diff --git a/sphinx/themes/epub/static/epub.css.jinja b/sphinx/themes/epub/static/epub.css.jinja index 306016bd301..afc1bec692a 100644 --- a/sphinx/themes/epub/static/epub.css.jinja +++ b/sphinx/themes/epub/static/epub.css.jinja @@ -2,6 +2,8 @@ * Sphinx stylesheet -- epub theme. */ +@import url("basic.css"); + /* -- main layout ----------------------------------------------------------- */ {% if theme_writing_mode is defined %} diff --git a/sphinx/themes/nonav/static/nonav.css.jinja b/sphinx/themes/nonav/static/nonav.css.jinja index f68ff88dcd6..6d92ac1e541 100644 --- a/sphinx/themes/nonav/static/nonav.css.jinja +++ b/sphinx/themes/nonav/static/nonav.css.jinja @@ -2,6 +2,8 @@ * Sphinx stylesheet -- nonav theme. */ +@import url("basic.css"); + /* -- main layout ----------------------------------------------------------- */ div.clearer { diff --git a/sphinx/themes/scrolls/static/scrolls.css.jinja b/sphinx/themes/scrolls/static/scrolls.css.jinja index 401449b8d9d..ffbd5002aa7 100644 --- a/sphinx/themes/scrolls/static/scrolls.css.jinja +++ b/sphinx/themes/scrolls/static/scrolls.css.jinja @@ -2,6 +2,8 @@ * Sphinx stylesheet -- scrolls theme. */ +@import url("basic.css"); + body { background-color: #222; margin: 0; diff --git a/sphinx/themes/traditional/static/traditional.css.jinja b/sphinx/themes/traditional/static/traditional.css.jinja index c5e829786d0..fe0410ea535 100644 --- a/sphinx/themes/traditional/static/traditional.css.jinja +++ b/sphinx/themes/traditional/static/traditional.css.jinja @@ -2,6 +2,8 @@ * Sphinx stylesheet -- traditional docs.python.org theme. */ +@import url("basic.css"); + body { color: #000; margin: 0; diff --git a/tests/test_theming/test_theming.py b/tests/test_theming/test_theming.py index 0237f5abb59..44fcb77a3c9 100644 --- a/tests/test_theming/test_theming.py +++ b/tests/test_theming/test_theming.py @@ -240,6 +240,34 @@ def test_theme_builds( pytest.fail(f'Failed to parse {html_file.relative_to(app.outdir)}: {exc}') +@pytest.mark.parametrize( + ('theme_name', 'css_name'), + [ + ('agogo', 'agogo.css'), + ('epub', 'epub.css'), + ('nonav', 'nonav.css'), + ('scrolls', 'scrolls.css'), + ('traditional', 'traditional.css'), + ], +) +def test_bundled_themes_import_basic_css( + make_app: Callable[..., SphinxTestApp], + rootdir: Path, + sphinx_test_tempdir: Path, + theme_name: str, + css_name: str, +) -> None: + """Bundled themes that inherit ``basic`` should import ``basic.css``.""" + testroot_path = rootdir / 'test-basic' + srcdir = sphinx_test_tempdir / f'test-theme-{theme_name}-css' + shutil.copytree(testroot_path, srcdir) + + app = make_app(srcdir=srcdir, confoverrides={'html_theme': theme_name}) + app.build() + css = (app.outdir / '_static' / css_name).read_text(encoding='utf8') + assert '@import url("basic.css");' in css + + def test_config_file_toml() -> None: config_path = HERE / 'theme.toml' cfg = _load_theme_toml(config_path)