diff --git a/docs/sphinx/source/_static/tooltipster_color_theming.css b/docs/sphinx/source/_static/tooltipster_color_theming.css new file mode 100644 index 0000000000..5804459549 --- /dev/null +++ b/docs/sphinx/source/_static/tooltipster_color_theming.css @@ -0,0 +1,10 @@ +/* Overrides for sphinx-hoverxref since it does not support a native dark theme, see */ +/* https://github.com/readthedocs/sphinx-hoverxref/issues/231 */ +/* Inspired by https://github.com/pybamm-team/PyBaMM/pull/3083 */ + +/* These will ensure that the tooltip inherits the pydata-sphinx-theme colours */ + +.tooltipster-sidetip.tooltipster-shadow.tooltipster-shadow-custom .tooltipster-content { + background-color: var(--pst-color-background) !important; + color: var(--pst-color-text-base) !important; +} diff --git a/docs/sphinx/source/conf.py b/docs/sphinx/source/conf.py index a08507c0b3..5c1a85ddc5 100644 --- a/docs/sphinx/source/conf.py +++ b/docs/sphinx/source/conf.py @@ -282,6 +282,8 @@ def setup(app): app.add_css_file("reference_format.css") # Add a warning banner at the top of the page if viewing the "latest" docs app.add_js_file("version-alert.js") + # Match the color theme of tooltips to PyData Sphinx Theme light/dark mode + app.add_css_file("tooltipster_color_theming.css") # -- Options for LaTeX output --------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 8464b7ce23..b368cc75df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ doc = [ 'sphinx-toggleprompt == 0.5.2', 'sphinx-favicon', 'solarfactors', - 'sphinx-hoverxref', + 'sphinx-hoverxref ~= 1.4.2', # when updating, check that _static/tooltipster_color_theming.css still works ] test = [ 'pytest',