Skip to contentSkip to conversation

doc: fix Sphinx build without RTD theme

PATCH In review Thomas Monjalon 1 participant 2 messages Oct 17, 2024 – Oct 18, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 doc: fix Sphinx build without RTD theme

DTS is using a specific configuration of Sphinx which is supported only with the theme Read The Docs. If not available, this error may be seen:
unsupported theme option 'collapse_navigation' given

In order to allow doc generation without this theme, a check is added to make the specific configuration optional.

Fixes 7f9326423a04 ("dts: add API doc generation")
---
 doc/guides/conf.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
doc/guides/conf.py +7 -7
index 200e98b0bc..b553d9d5bf 100644
@@ -16,13 +16,12 @@
 
 try:
     import sphinx_rtd_theme
-
     html_theme = "sphinx_rtd_theme"
-except:
+except ImportError:
     print('Install the sphinx ReadTheDocs theme for improved html documentation '
           'layout: https://sphinx-rtd-theme.readthedocs.io/',
           file=stderr)
-    pass
+    html_theme = "default"
 
 stop_on_error = ('-W' in argv)
 
@@ -85,10 +84,11 @@
     toc_object_entries = True
     toc_object_entries_show_parents = 'hide'
     # DTS Sidebar config.
-    html_theme_options = {
-        'collapse_navigation': False,
-        'navigation_depth': -1,  # unlimited depth
-    }
+    if html_theme == "sphinx_rtd_theme":
+        html_theme_options = {
+            'collapse_navigation': False,
+            'navigation_depth': -1,  # unlimited depth
+        }
 
     # Add path to DTS sources so that Sphinx can find them.
     dpdk_root = dirname(dirname(dirname(__file__)))
Signature · 1 line
2.46.0
#1 lore raw

17/10/2024 19:14, Thomas Monjalon:

Quoted 5 lines

DTS is using a specific configuration of Sphinx which is supported only with the theme Read The Docs. If not available, this error may be seen:
unsupported theme option 'collapse_navigation' given

Quoted 7 lines

In order to allow doc generation without this theme, a check is added to make the specific configuration optional.

Fixes 7f9326423a04 ("dts: add API doc generation")

Was applied quickly to fix the build.