[rtems-docs commit] Add a check for Sphinx extensions.

Chris Johns chrisj at rtems.org
Sat Feb 25 04:06:40 UTC 2017


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

Author:    Chris Johns <chrisj at rtems.org>
Date:      Sat Feb 25 15:05:09 2017 +1100

Add a check for Sphinx extensions.

Minor clean up of the configure messages.

Do not re-check sphinx in the nested configures.

---

 common/waf.py | 59 ++++++++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 44 insertions(+), 15 deletions(-)

diff --git a/common/waf.py b/common/waf.py
index 8aeac5d..ad75ed5 100644
--- a/common/waf.py
+++ b/common/waf.py
@@ -134,21 +134,52 @@ def html_resources(ctx, buildtype):
 #    )
 
 
-def cmd_configure(ctx):
-    ctx.find_program("sphinx-build", var="BIN_SPHINX_BUILD", mandatory = True)
-    ctx.find_program("aspell", var = "BIN_ASPELL", mandatory = False)
+def check_sphinx_extension(ctx, extension):
+    def run_sphinx(bld):
+        rst_node = bld.srcnode.make_node('testbuild/contents.rst')
+        rst_node.parent.mkdir()
+        rst_node.write('.. COMMENT test sphinx\n')
+        bld(rule = bld.kw['rule'], source = rst_node)
+
+    ctx.start_msg("Checking for '%s'" % (extension))
+    try:
+        ctx.run_build(fragment = 'xx',
+                      rule = "${BIN_SPHINX_BUILD} -b html -D extensions=%s -C . out" % (extension),
+                      build_fun = run_sphinx,
+                      env = ctx.env)
+    except ctx.errors.ConfigurationError:
+        ctx.end_msg('not found (see README.txt)', 'RED')
+        ctx.fatal('The configuration failed')
+    ctx.end_msg('found')
 
-    ctx.start_msg("Checking if Sphinx is at least %s.%s" % sphinx_min_version)
-    ver = check_sphinx_version(ctx, sphinx_min_version)
-    ctx.end_msg("yes (%s)" % ".".join(map(str, ver)))
 
-    ctx.start_msg("Sphinx Verbose: ")
-    if 'SPHINX_VERBOSE' not in ctx.env:
-        ctx.env.append_value('SPHINX_VERBOSE', ctx.options.sphinx_verbose)
-    level = sphinx_verbose(ctx)
-    if level == '-Q':
-        level = 'quiet'
-    ctx.end_msg(level)
+def cmd_configure(ctx):
+    check_sphinx = not ctx.env.BIN_SPHINX_BUILD
+    if check_sphinx:
+        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)
+        ctx.end_msg("yes (%s)" % ".".join(map(str, ver)))
+
+        ctx.start_msg("Checking Sphinx Verbose ")
+        if 'SPHINX_VERBOSE' not in ctx.env:
+            ctx.env.append_value('SPHINX_VERBOSE', ctx.options.sphinx_verbose)
+            level = sphinx_verbose(ctx)
+            if level == '-Q':
+                level = 'quiet'
+            ctx.end_msg(level)
+        #
+        # Check extensions.
+        #
+        check_sphinx_extension(ctx, 'sphinx.ext.autodoc')
+        check_sphinx_extension(ctx, 'sphinx.ext.coverage')
+        check_sphinx_extension(ctx, 'sphinx.ext.doctest')
+        check_sphinx_extension(ctx, 'sphinx.ext.graphviz')
+        check_sphinx_extension(ctx, 'sphinx.ext.intersphinx')
+        check_sphinx_extension(ctx, 'sphinx.ext.mathjax')
+        check_sphinx_extension(ctx, 'sphinxcontrib.bibtex')
 
     #
     # Optional builds.
@@ -164,8 +195,6 @@ def cmd_configure(ctx):
                '-shell-escape' not in ctx.env['PDFLATEXFLAGS']:
                 ctx.env.append_value('PDFLATEXFLAGS', '-shell-escape')
             latex.configure_tests(ctx)
-        else:
-            ctx.msg('Check for Tex packages', 'skipping, already checked')
         ctx.env.BUILD_PDF = 'yes'
 
     ctx.envBUILD_SINGLEHTML = 'no'




More information about the vc mailing list