Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Support dark mode in the documentation (#6653)

anubhavf041f26a6ff6
diff --git a/docs/_static/custom.css b/docs/_static/custom.css
index 64f16939c..1c2859deb 100644
--- a/docs/_static/custom.css
+++ b/docs/_static/custom.css
@@ -7,4 +7,50 @@
}
.rst-content dl p + ol, .rst-content dl p + ul {
margin-top: -6px; /* Compensates margin-top: 12px of p */
-}
\ No newline at end of file
+}
+
+/*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
+}
diff --git a/docs/conf.py b/docs/conf.py
index be5e07195..1167ce050 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -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
diff --git a/docs/requirements.txt b/docs/requirements.txt
index e2abe76d9..103fb08d6 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -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