From 9d652e28f4de41fe3280d6bd4a4b80270d1d655b Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Sun, 4 Dec 2022 11:02:02 -0500
Subject: Fall back to alabaster if sphinx_lv2_theme is unavailable

---
 doc/conf.py.in | 108 +++++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 75 insertions(+), 33 deletions(-)

(limited to 'doc/conf.py.in')

diff --git a/doc/conf.py.in b/doc/conf.py.in
index cefa9e9..1fa288f 100644
--- a/doc/conf.py.in
+++ b/doc/conf.py.in
@@ -17,6 +17,13 @@ language = "en"
 nitpicky = True
 pygments_style = "friendly"
 
+try:
+    import sphinx_lv2_theme
+
+    have_lv2_theme = True
+except ModuleNotFoundError:
+    have_lv2_theme = False
+
 # Ignore everything opaque or external for nitpicky mode
 _opaque = [
     "FILE",
@@ -56,38 +63,73 @@ nitpick_ignore = list(_c_nitpick_ignore) + list(_cpp_nitpick_ignore)
 html_copy_source = False
 html_secnumber_suffix = " "
 html_short_title = "@ZIX_TITLE@"
-html_theme = "sphinx_lv2_theme"
-
-if tags.has("singlehtml"):
-    html_sidebars = {
-        "**": [
-            "globaltoc.html",
-        ]
-    }
-
-    html_theme_options = {
-        "body_max_width": "46em",
-        "body_min_width": "46em",
-        "description": desc,
-        "globaltoc_collapse": False,
-        "globaltoc_maxdepth": 3,
-        "logo_name": True,
-        "nosidebar": False,
-        "page_width": "80em",
-        "show_footer_version": True,
-        "show_logo_version": True,
-        "sidebar_width": "14em",
-    }
 
+if have_lv2_theme:
+    html_theme = "sphinx_lv2_theme"
+
+    if tags.has("singlehtml"):
+        html_sidebars = {
+            "**": [
+                "globaltoc.html",
+            ]
+        }
+
+        html_theme_options = {
+            "body_max_width": "46em",
+            "body_min_width": "46em",
+            "description": desc,
+            "globaltoc_collapse": False,
+            "globaltoc_maxdepth": 3,
+            "logo_name": True,
+            "nosidebar": False,
+            "page_width": "80em",
+            "show_footer_version": True,
+            "show_logo_version": True,
+            "sidebar_width": "14em",
+        }
+
+    else:
+        html_theme_options = {
+            "body_max_width": "60em",
+            "body_min_width": "46em",
+            "description": desc,
+            "logo_name": True,
+            "nosidebar": True,
+            "page_width": "60em",
+            "show_footer_version": True,
+            "show_logo_version": True,
+            "sidebar_width": "14em",
+        }
 else:
-    html_theme_options = {
-        "body_max_width": "60em",
-        "body_min_width": "46em",
-        "description": desc,
-        "logo_name": True,
-        "nosidebar": True,
-        "page_width": "60em",
-        "show_footer_version": True,
-        "show_logo_version": True,
-        "sidebar_width": "14em",
-    }
+    html_theme = "alabaster"
+    html_static_path = ["@ZIX_SRCDIR@/doc/_static"]
+
+    if tags.has("singlehtml"):
+        html_sidebars = {
+            "**": [
+                "globaltoc.html",
+            ]
+        }
+
+        html_theme_options = {
+            "body_max_width": "48em",
+            "body_min_width": "48em",
+            "description": desc,
+            "globaltoc_collapse": False,
+            "globaltoc_maxdepth": 3,
+            "logo_name": True,
+            "nosidebar": False,
+            "page_width": "80em",
+            "sidebar_width": "16em",
+        }
+
+    else:
+        html_theme_options = {
+            "body_max_width": "60em",
+            "body_min_width": "40em",
+            "description": desc,
+            "logo_name": True,
+            "nosidebar": True,
+            "page_width": "60em",
+            "show_relbars": True,
+        }
-- 
cgit v1.2.1