@@ -58,6 +58,44 @@ get_build_type() {
58
58
return
59
59
fi
60
60
changed_examples=$( echo " $filenames " | grep -E " ^examples/(.*/)*plot_" )
61
+
62
+ # The following is used to extract the list of filenames of example python
63
+ # files that sphinx-gallery needs to run to generate png files used as
64
+ # figures or images in the .rst files from the documentation.
65
+ # If the contributor changes a .rst file in a PR we need to run all
66
+ # the examples mentioned in that file to get sphinx build the
67
+ # documentation without generating spurious warnings related to missing
68
+ # png files.
69
+
70
+ if [[ -n " $filenames " ]]
71
+ then
72
+ # get rst files
73
+ rst_files=" $( echo " $filenames " | grep -E " rst$" ) "
74
+
75
+ # get lines with figure or images
76
+ img_fig_lines=" $( echo " $rst_files " | xargs grep -shE " (figure|image)::" ) "
77
+
78
+ # get only auto_examples
79
+ auto_example_files=" $( echo " $img_fig_lines " | grep auto_examples | awk -F " /" ' {print $NF}' ) "
80
+
81
+ # remove "sphx_glr_" from path and accept replace _(\d\d\d|thumb).png with .py
82
+ scripts_names=" $( echo " $auto_example_files " | sed ' s/sphx_glr_//' | sed -e ' s/_([[:digit:]][[:digit:]][[:digit:]]|thumb).png/.py/' ) "
83
+
84
+ # get unique values
85
+ examples_in_rst=" $( echo " $scripts_names " | uniq ) "
86
+ fi
87
+
88
+ # executed only if there are examples in the modified rst files
89
+ if [[ -n " $examples_in_rst " ]]
90
+ then
91
+ if [[ -n " $changed_examples " ]]
92
+ then
93
+ changed_examples=" $changed_examples |$examples_in_rst "
94
+ else
95
+ changed_examples=" $examples_in_rst "
96
+ fi
97
+ fi
98
+
61
99
if [[ -n " $changed_examples " ]]
62
100
then
63
101
echo BUILD: detected examples/ filename modified in $git_range : $changed_examples
@@ -204,5 +242,12 @@ then
204
242
echo " $warnings " | sed ' s/\/home\/circleci\/project\//<li>/g'
205
243
echo ' </ul></body></html>'
206
244
) > ' doc/_build/html/stable/_changed.html'
245
+
246
+ if [ " $warnings " != " /home/circleci/project/ no warnings" ]
247
+ then
248
+ echo " Sphinx generated warnings when building the documentation related to files modified in this PR."
249
+ echo " Please check doc/_build/html/stable/_changed.html"
250
+ exit 1
251
+ fi
207
252
fi
208
253
0 commit comments