Skip to contentSkip to conversation

docs: fix themes with newer Sphinx and RTD themes

PATCH In review Mauro Carvalho Chehab 2 participants 3 messages Nov 27, 2021 Documentation

lore
Share & tools
lore
#0 lore raw

v2 cover docs: fix themes with newer Sphinx and RTD themes

Hi Jon,

That's the second version of the patch fixing themes with newer versions of Sphinx and RTD themes.

On my past version, the theme was not actually applied on newer Kernels, causing a regresion. This version addresses it. It also takes Laurent's suggestion into account.

As this is actually a fix, I would pick it, independently on the discussions if we should keep using RTD theme or not.

Regards,
Mauro

Mauro Carvalho Chehab (1):
docs: conf.py: fix support for Readthedocs v 1.0.0

 Documentation/conf.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
Signature · 1 line
2.33.1
#1 lore raw

PATCH v2 1/1 docs: conf.py: fix support for Readthedocs v 1.0.0

As described at:
https://stackoverflow.com/questions/23211695/modifying-content-width-of-the-sphinx-theme-read-the-docs

since Sphinx 1.8, the standard way to setup a custom theme is to use html_css_files. While using html_context is OK with RTD 0.5.2, it doesn't work with 1.0.0, causing the theme to not load, producing a very weird html.

Tested with:
- Sphinx 1.7.9 + sphinx-rtd-theme 0.5.2
- Sphinx 2.4.4 + sphinx-rtd-theme 0.5.2
- Sphinx 2.4.4 + sphinx-rtd-theme 1.0.0
- Sphinx 4.3.0 + sphinx-rtd-theme 1.0.0

---

See [PATCH v2 0/1] at: https://lore.kernel.org/all/[email protected]/

 Documentation/conf.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
Documentation/conf.py +10 -5
index 17f7cee56987..76e5eb5cb62b 100644
@@ -249,11 +249,16 @@ except ImportError:
 
 html_static_path = ['sphinx-static']
 
-html_context = {
-    'css_files': [
-        '_static/theme_overrides.css',
-    ],
-}
+html_css_files = [
+    'theme_overrides.css',
+]
+
+if major <= 1 and minor < 8:
+    html_context = {
+        'css_files': [
+            '_static/theme_overrides.css',
+        ],
+    }
 
 # Add any extra paths that contain custom files (such as robots.txt or
 # .htaccess) here, relative to this directory. These files are copied
Signature · 1 line
2.33.1
Tested-by on v2 1/1
#2 lore raw

Re: [PATCH v2 1/1] docs: conf.py: fix support for Readthedocs v 1.0.0

Quoted 14 lines · Mauro Carvalho Chehab

As described at:
https://stackoverflow.com/questions/23211695/modifying-content-width-of-the-sphinx-theme-read-the-docs

since Sphinx 1.8, the standard way to setup a custom theme is to use html_css_files. While using html_context is OK with RTD 0.5.2, it doesn't work with 1.0.0, causing the theme to not load, producing a very weird html.

Tested with:
- Sphinx 1.7.9 + sphinx-rtd-theme 0.5.2
- Sphinx 2.4.4 + sphinx-rtd-theme 0.5.2
- Sphinx 2.4.4 + sphinx-rtd-theme 1.0.0
- Sphinx 4.3.0 + sphinx-rtd-theme 1.0.0

Quoted 7 lines

---

See [PATCH v2 0/1] at: https://lore.kernel.org/all/[email protected]/

Hi Mauro,

Good to see the nice looking HTML pages as before!

Thanks, Akira

Quoted 31 lines
 Documentation/conf.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
Documentation/conf.py +10 -5
index 17f7cee56987..76e5eb5cb62b 100644
@@ -249,11 +249,16 @@ except ImportError:
 
 html_static_path = ['sphinx-static']
 
-html_context = {
-    'css_files': [
-        '_static/theme_overrides.css',
-    ],
-}
+html_css_files = [
+    'theme_overrides.css',
+]
+
+if major <= 1 and minor < 8:
+    html_context = {
+        'css_files': [
+            '_static/theme_overrides.css',
+        ],
+    }
 
 # Add any extra paths that contain custom files (such as robots.txt or
 # .htaccess) here, relative to this directory. These files are copied