-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.sh
executable file
·80 lines (65 loc) · 2.63 KB
/
build.sh
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
set -e
INPUT_DIR="workshops/docs/modules/notebooks"
OUT_DIR="workshops/docs/modules"
TEMPLATE_DIR="workshops/docs/modules/notebooks/nbconvert_templates"
# We omit --allow-errors when executing to catch and broken examples.
# Any example that requires printing a traceback should be moved into a
# Markdown example cell so that code is displayed by not executed.
# ggplot/plotnine cells are sometimes slow, so we increase the default timeout
# EXECUTE="--execute --allow-errors --ExecutePreprocessor.timeout=240"
EXECUTE="--execute --ExecutePreprocessor.timeout=240"
generate_html='no'
generate_instructor_notes='no'
index=1
for f in ${INPUT_DIR}/*.ipynb; do
fn=$(basename -- "$f")
name="${fn%.*}"
if [ -d ${OUT_DIR}/${name}_files ]; then
echo "Removing old generated images at ${OUT_DIR}/${name}_files"
rm -rf ${OUT_DIR}/${name}_files
fi
printf -v i "%02d" $index
if [[ generate_html == 'yes' ]]; then
if [[ generate_instructor_notes == 'yes' ]]; then
jupyter nbconvert ${EXECUTE} \
--to html \
--config=export_config.py \
--output-dir=$OUT_DIR \
--template=$TEMPLATE_DIR/instructor.tpl \
--output=${name}_instructor_notes.html \
$INPUT_DIR/${name}.ipynb
fi
jupyter nbconvert ${EXECUTE} \
--to html \
--config=export_config.py \
--output-dir=$OUT_DIR \
--template=$TEMPLATE_DIR/student.tpl \
--output=${name}.html \
$INPUT_DIR/${name}.ipynb
fi
if [[ generate_instructor_notes == 'yes' ]]; then
jupyter nbconvert ${EXECUTE} \
--to markdown \
--config=export_config.py \
--output-dir=$OUT_DIR \
--template=$TEMPLATE_DIR/instructor_markdown.tpl \
--output=${name}_instructor_notes.md \
$INPUT_DIR/${name}.ipynb
fi
jupyter nbconvert ${EXECUTE} \
--to markdown \
--config=export_config.py \
--output-dir=$OUT_DIR \
--template=$TEMPLATE_DIR/student_markdown.tpl \
--output=${name}.md \
$INPUT_DIR/${name}.ipynb
let "index++"
done
#jupyter nbconvert --to slides --output-dir=docs/slides \
# --reveal-prefix reveal.js \
# --output=Preamble \
# docs/slides/Preamble.ipynb
cd workshops
mkdocs build
cd ..