Support dark mode in the documentation (#6653)

This commit is contained in:
anubhav 2025-02-06 22:37:07 +05:30 committed by GitHub
parent 4e0a3087e4
commit f041f26a6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 51 additions and 1 deletions

View File

@ -7,4 +7,50 @@
}
.rst-content dl p + ol, .rst-content dl p + ul {
margin-top: -6px; /* Compensates margin-top: 12px of p */
}
}
/*override some styles in
sphinx-rtd-dark-mode/static/dark_mode_css/general.css*/
.theme-switcher {
right: 0.4em !important;
top: 0.6em !important;
-webkit-box-shadow: 0px 3px 14px 4px rgba(0, 0, 0, 0.30) !important;
box-shadow: 0px 3px 14px 4px rgba(0, 0, 0, 0.30) !important;
height: 2em !important;
width: 2em !important;
}
/*place the toggle button for dark mode
at the bottom right corner on small screens*/
@media (max-width: 768px) {
.theme-switcher {
right: 0.4em !important;
bottom: 2.6em !important;
top: auto !important;
}
}
/*persist blue color at the top left used in
default rtd theme*/
html[data-theme="dark"] .wy-side-nav-search,
html[data-theme="dark"] .wy-nav-top {
background-color: #1d577d !important;
}
/*all the styles below used to present
API objects nicely in dark mode*/
html[data-theme="dark"] .sig.sig-object {
border-left-color: #3e4446 !important;
background-color: #202325 !important
}
html[data-theme="dark"] .sig-name,
html[data-theme="dark"] .sig-prename,
html[data-theme="dark"] .property,
html[data-theme="dark"] .sig-param,
html[data-theme="dark"] .sig-paren,
html[data-theme="dark"] .sig-return-icon,
html[data-theme="dark"] .sig-return-typehint,
html[data-theme="dark"] .optional {
color: #e8e6e3 !important
}

View File

@ -35,6 +35,7 @@ extensions = [
"sphinx.ext.coverage",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinx_rtd_dark_mode",
]
templates_path = ["_templates"]
@ -174,3 +175,5 @@ hoverxref_role_types = {
"signal": "tooltip",
}
hoverxref_roles = ["command", "reqmeta", "setting", "signal"]
default_dark_mode = False

View File

@ -2,3 +2,4 @@ sphinx==8.1.3
sphinx-hoverxref==1.4.2
sphinx-notfound-page==1.0.4
sphinx-rtd-theme==3.0.2
sphinx-rtd-dark-mode==1.3.0