Skip to content

Commit dfff675

Browse files
committed
oac_setup_sphinx: test Sphinx rendering
If we find Sphinx, also check that we can render a trivial Open MPI/PRRTE/OpenPMIx-like Sphinx document (i.e., that uses the same kinds of Sphinx plugins and modules that Open MPI/etc. uses). Signed-off-by: Jeff Squyres <jeff@squyres.com>
1 parent c1cfc91 commit dfff675

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

oac_setup_sphinx.m4

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
dnl -*- autoconf -*-
22
dnl
33
dnl Copyright (c) 2020-2022 Cisco Systems, Inc. All rights reserved.
4+
dnl Copyright (c) 2024 Jeffrey M. Squyres. All rights reserved.
45
dnl
56
dnl $COPYRIGHT$
67
dnl
@@ -20,6 +21,10 @@ dnl If $2 is empty, nothing will be displayed.
2021
dnl Note: if $2 contains a #, be sure to double quote it
2122
dnl (e.g., [[https://example.com/foo.html#some-anchor]])
2223
dnl
24+
dnl 3 -> (OPTIONAL) Filename of requirements.txt-like file containing
25+
dnl the required Pip modules (to be displayed if rendering a
26+
dnl simple RST project fails).
27+
dnl
2328
dnl This macro requires that OAC_PUSH_PREFIX was previously called.
2429
dnl The pushed prefix may be used if this macro chooses to set {OAC
2530
dnl prefix}_MAKEDIST_DISABLE. If set, it is a message indicating why
@@ -90,9 +95,54 @@ AC_DEFUN([OAC_SETUP_SPHINX],[
9095
AC_MSG_RESULT([yes])])
9196
])
9297
98+
# If we found Sphinx, check to ensure that we have all the things
99+
# required to build Open MPI/PRRTE/OpenPMIx-like documentation
100+
# (e.g., any required pip modules). If we can't render a sample
101+
# OMPI-like doc, we're not going to automatically install any
102+
# missing pip modules; we'll just mark Sphinx as being
103+
# unavailable.
104+
AS_IF([test -n "$SPHINX_BUILD"],
105+
[AC_MSG_CHECKING([for required Sphinx modules])
106+
oac_startdir=`pwd`
107+
oac_tmpdir=conftmp.$$
108+
rm -rf $oac_tmpdir
109+
mkdir $oac_tmpdir
110+
cd $oac_tmpdir
111+
cat > conf.py <<EOF
112+
# Minimum config that we need for Open MPI/PRRTE/OpenPMIx-like docs
113+
project = 'Testing'
114+
copyright = 'Testing'
115+
author = 'Testing'
116+
import sphinx_rtd_theme
117+
# Note the extra quoting needed for square brackets because this is m4
118+
extensions = [[ 'recommonmark', 'sphinx_rtd_theme', 'sphinx.ext.extlinks' ]]
119+
html_theme = 'sphinx_rtd_theme'
120+
EOF
121+
echo "Hello world" > index.rst
122+
123+
# Try to render this trivial RST project as both HTML and
124+
# man pages and see if it works.
125+
oac_happy=0
126+
OAC_LOG_COMMAND([$SPHINX_BUILD -M html . build-html],
127+
[OAC_LOG_COMMAND([$SPHINX_BUILD -M man . build-man],
128+
[oac_happy=1])])
129+
AS_IF([test $oac_happy -eq 1],
130+
[AC_MSG_RESULT([found])],
131+
[SPHINX_BUILD=
132+
AC_MSG_RESULT([not found])])
133+
134+
cd $oac_startdir
135+
rm -rf $oac_tmpdir
136+
])
137+
93138
AS_IF([test -z "$SPHINX_BUILD"],
94139
_oac_program_prefix[_MAKEDIST_DISABLE="$]_oac_program_prefix[_MAKEDIST_DISABLE Sphinx/Documentation"
95140
AC_MSG_NOTICE([Could not find a suitable sphinx-build on your system.])
141+
AS_IF([test -n "$3"],
142+
[AC_MSG_NOTICE([If you want to build the documentation, ensure that the])
143+
AC_MSG_NOTICE([Python modules in $3])
144+
AC_MSG_NOTICE([are available.])
145+
])
96146
AC_MSG_NOTICE([You will not be able to build a distribution tarball.])
97147
])
98148
@@ -107,7 +157,7 @@ AC_DEFUN([OAC_SETUP_SPHINX],[
107157
# abort. This is likely only useful to prevent "oops!" moments
108158
# from developers.
109159
AS_IF([test -z "$SPHINX_BUILD" && test "$enable_sphinx" = "yes"],
110-
[AC_MSG_WARN([Sphinx was not found, but --enable-sphinx was specified])
160+
[AC_MSG_WARN([A suitable Sphinx was not found, but --enable-sphinx was specified])
111161
AC_MSG_ERROR([Cannot continue])])
112162
113163
# Construct a summary message. Due SUMMARY_ADD's implementation,

0 commit comments

Comments
 (0)