forked from StevenJokes/d2l-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_html.sh
executable file
·59 lines (47 loc) · 1.38 KB
/
build_html.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
#!/usr/bin/env bash
# build_html.sh
# build website based on jupyter notebooks
set -e
rm -rf _build
rm -r -f */temp.ipynb
output_dir=_build/eval
mkdir -p $output_dir
aws s3 sync s3://d2l-java-resources/d2l-original .
mkdir -p $output_dir/img
cp -r img/* $output_dir/img
cp d2l.bib $output_dir
d2lbook build eval
function eval {
base=$(basename $1)
dir=$(dirname $1)
if [ -f "$output_dir/$1" ]; then
echo "$output_dir/$1 exists, skipping."
return 0
fi
echo "Evaluating file: $1"
echo "saving output to: $output_dir/$1"
jupyter nbconvert --to notebook --execute --ExecutePreprocessor.timeout=600 --output temp "$1"
mkdir -p $output_dir/$dir
mv "$dir/temp.ipynb" "$output_dir/$1"
}
for f in **/*.ipynb
do
eval "$f"
done
rm -r -f */temp.ipynb
pip3 install git+https://github.com/roywei/d2l-book.git@d2l-java
d2lbook build rst
cp static/frontpage/frontpage.html _build/rst/frontpage.html
d2lbook build html
mkdir -p _build/html/_images/
cp -r static/frontpage/_images/* _build/html/_images/
for fn in `find _build/html/_images/ -iname '*.svg' `; do
if [[ $fn == *'qr_'* ]] ; then # || [[ $fn == *'output_'* ]]
continue
fi
# rsvg-convert installed on ubuntu changes unit from px to pt, so evening no
# change of the size makes the svg larger...
rsvg-convert -z 1 -f svg -o tmp.svg $fn
mv tmp.svg $fn
done
d2lbook build pdf