1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#!/bin/bash
NB="$1"
# check whether we want to build everything or just one ipynb
if [ ! -z "$NB" ]; then
if [ ! -f "$NB" ]; then
echo "E: notebook file ($NB) is not available"
exit 1
fi
fi
# create *.ipynb ...
if [ ! -d docs ]; then
echo "E: directory docs needs to be a subdirectory"
exit 1
fi
cd docs
# ... but only if we want to build everything
if [ -z "$NB" ]; then
rm -rf build
make html
fi
cd ..
if [ -z "$NB" ]; then
ipynb=`find ./docs/build/html/examples/*|grep "\.ipynb$"`
else
ipynb="$NB"
fi
echo "I: complete list: $ipynb"
# now do the hard work
TMPOUTPUT=/tmp/pppppppp
for i in $ipynb; do
if [ -f $i ]; then
echo -n "I: work on $i"
jupyter nbconvert --to notebook --execute $i &> $TMPOUTPUT
rc=$?
echo " -> $rc"
if [ "$rc" != "0" ]; then
cat $TMPOUTPUT
fi
fi
done
rm -f $TMPOUTPUT
|