python / python-docs-theme

Sphinx theme for Python documentation
Other
76 stars 59 forks source link

Dark mode: topic background colour not applied in Sphinx 6.2.0 #132

Closed hugovk closed 1 year ago

hugovk commented 1 year ago

Currently the 3.12 docs are built with Sphinx 4.5.0 (it's shown in the page footer) and 3.13 with Sphinx 6.2.0.

Compare these pages in dark mode:

Python 3.12 / Sphinx 4.5.0 Python 3.13 / Sphinx 6.2.0
image image

Looks fine in light mode:

Python 3.12 / Sphinx 4.5.0 Python 3.13 / Sphinx 6.2.0
image image

Previously, we had this CSS from pydoctheme_dark.css applied to <div class="contents local topic" id="contents">:

div.topic,
div.note {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: currentColor;
}

But now the HTML structure has changed to <nav class="contents local" id="contents"> so the CSS doesn't apply.

The source RST:

.. contents::
   :depth: 1
   :local:
hugovk commented 1 year ago

Bisecting the Sphinx releases, this first occurred between Sphinx 5.0.1 and 5.0.2.

Checking the diff:

https://github.com/sphinx-doc/sphinx/compare/v5.0.1...v5.0.2

Which contains this commit: https://github.com/sphinx-doc/sphinx/commit/5806f0af2788db40661d62e5e88c2c1560ae46b6

Add nav.contents everywhere that div.topic is used

From this PR: https://github.com/sphinx-doc/sphinx/pull/10535

Which fixed this issue: https://github.com/sphinx-doc/sphinx/issues/10534

Which said:

Previously, docutils produced div.topic for the contents directive, the latest version produces nav.contents.

This means that those tables of contents change appearance when switching to docutils 0.18.

So let's try the same fix as https://github.com/sphinx-doc/sphinx/commit/5806f0af2788db40661d62e5e88c2c1560ae46b6.

hugovk commented 1 year ago

Another page affected by this:

hugovk commented 1 year ago

Please see PR #138 to fix this.