[rtems-docs commit] common/waf.py: Add option to check maximum Sphinx version

Joel Sherrill joel at rtems.org
Wed Jul 26 18:38:08 UTC 2023


Module:    rtems-docs
Branch:    master
Commit:    fbcae108102bb73bff1f6c7dbcba969612a387e5
Changeset: http://git.rtems.org/rtems-docs/commit/?id=fbcae108102bb73bff1f6c7dbcba969612a387e5

Author:    Joel Sherrill <joel at rtems.org>
Date:      Tue Jul 25 15:19:16 2023 -0500

common/waf.py: Add option to check maximum Sphinx version

Updates #4928.

---

 common/waf.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/common/waf.py b/common/waf.py
index 0bd166a..6efe038 100644
--- a/common/waf.py
+++ b/common/waf.py
@@ -16,7 +16,11 @@ from waflib.Build import BuildContext
 import latex
 import conf
 
+# Sphinx >= 6 are currently broken. 
+# If you do not want to check for a maximum version, set it to None.
 sphinx_min_version = (1, 3)
+sphinx_max_version = (5, 9)
+#sphinx_max_version = None
 
 def version_cmdline(ctx):
     return '-Drelease="%s" -Dversion="%s" -Drtems_major="%s" ' \
@@ -84,7 +88,7 @@ class linkcheck(BuildContext):
     cmd = 'linkcheck'
     fun = 'cmd_linkcheck'
 
-def check_sphinx_version(ctx, minver):
+def check_sphinx_version(ctx, minver, maxver):
     try:
         import sphinx
     except:
@@ -115,6 +119,9 @@ def check_sphinx_version(ctx, minver):
                 ctx.fatal("Sphinx version cannot be checked or Sphinx is not installed")
     if ver < minver:
         ctx.fatal("Sphinx version is too old: %s" % ".".join(map(str, ver)))
+    if maxver is not None:
+        if ver > maxver:
+            ctx.fatal("Sphinx version is too new: %s" % ".".join(map(str, ver)))
     return ver
 
 def sphinx_options(ctx):
@@ -206,8 +213,12 @@ def cmd_configure(ctx):
         ctx.find_program("sphinx-build", var="BIN_SPHINX_BUILD", mandatory = True)
         ctx.find_program("aspell", var = "BIN_ASPELL", mandatory = False)
 
-        ctx.start_msg("Checking if Sphinx is at least %s.%s" % sphinx_min_version)
-        ver = check_sphinx_version(ctx, sphinx_min_version)
+        if sphinx_max_version is None:
+          ctx.start_msg("Checking if Sphinx is at least %s.%s" % sphinx_min_version)
+        else:
+          ctx.start_msg("Checking if Sphinx is between %s.%s and %s.%s" % (sphinx_min_version + sphinx_max_version))
+
+        ver = check_sphinx_version(ctx, sphinx_min_version, sphinx_max_version)
         ctx.end_msg("yes (%s)" % ".".join(map(str, ver)))
 
         ctx.start_msg("Checking Sphinx Options ")



More information about the vc mailing list