This is an automated email from the ASF dual-hosted git repository.

paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git


The following commit(s) were added to refs/heads/main by this push:
     new d3ae37b  Add version switcher to documentation build (#307)
d3ae37b is described below

commit d3ae37b5d129aef483d845a1f1b06709af594fc1
Author: Dewey Dunnington <[email protected]>
AuthorDate: Tue Sep 26 10:30:24 2023 -0300

    Add version switcher to documentation build (#307)
    
    Closes #303.
---
 docs/source/conf.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/docs/source/conf.py b/docs/source/conf.py
index 2365631..a6fa729 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -17,6 +17,7 @@
 
 import datetime
 import os
+import re
 import sys
 
 # Configuration file for the Sphinx documentation builder.
@@ -39,6 +40,17 @@ copyright = f"2016-{datetime.datetime.now().year} Apache 
Software Foundation"
 author = "Apache Software Foundation"
 
 
+def get_version():
+    cmakelists = os.path.join("..", "..", "CMakeLists.txt")
+    with open(cmakelists, "r") as f:
+        for line in f:
+            if "NANOARROW_VERSION" in line:
+                if "SNAPSHOT" in line:
+                    return "dev"
+                else:
+                    return re.findall(r"[0-9]+\.[0-9]+\.[0-9]+", line)[0]
+
+
 # -- General configuration ---------------------------------------------------
 
 # Add any Sphinx extension module names here, as strings. They can be
@@ -77,6 +89,11 @@ html_theme_options = {
     "show_toc_level": 2,
     "use_edit_page_button": True,
     "external_links": [],
+    "switcher": {
+        "json_url": "https://arrow.apache.org/nanoarrow/switcher.json";,
+        "version_match": get_version(),
+    },
+    "navbar_start": ["navbar-logo", "version-switcher"],
 }
 
 html_context = {

Reply via email to