forked from flatland-association/flatland-book
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
37 lines (31 loc) · 1.95 KB
/
build.sh
File metadata and controls
37 lines (31 loc) · 1.95 KB
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
set -e
set -x
FLATLAND_MODULE_PATH=$(python -c 'import os; import importlib; print(os.path.dirname(importlib.import_module("flatland").__file__))')
FLATLAND_MODULE_VERSION=$(python -c "import flatland; print(flatland.__version__)")
cp ${FLATLAND_MODULE_PATH}/../notebooks/graph_demo.ipynb environment/environment
cp ${FLATLAND_MODULE_PATH}/../notebooks/Agent-Close-Following.ipynb environment/environment
cp -R ${FLATLAND_MODULE_PATH}/../notebooks/images/ environment/environment/images/
sphinx-apidoc --force -a -e -o apidocs ${FLATLAND_MODULE_PATH} -H "Flatland ${FLATLAND_MODULE_VERSION} API Reference" --tocfile 'index'
# tweak mermaid directives for sphinx, see https://sphinxcontrib-mermaid-demo.readthedocs.io/en/latest/index.html
if [ "$(uname)" == "Darwin" ]; then
# sed works differently under macOS...
find . -name "*.md" -print0 | xargs -0 sed -i '' 's/```mermaid/```{mermaid}/g'
find . -name "*.ipynb" -print0 | xargs -0 sed -i '' 's/```mermaid/```{mermaid}/g'
else
find . -name "*.md" -print0 | xargs -0 sed -i 's/```mermaid/```{mermaid}/g'
find . -name "*.ipynb" -print0 | xargs -0 sed -i 's/```mermaid/```{mermaid}/g'
fi
jupyter-book clean .
jupyter-book build .
# revert tweak mermaid directives for sphinx
if [ "$(uname)" == "Darwin" ]; then
# sed works differently under macOS...
find . -name "*.md" -print0 | xargs -0 sed -i '' 's/```{mermaid}/```mermaid/g'
find . -name "*.ipynb" -print0 | xargs -0 sed -i '' 's/```{mermaid}/```mermaid/g'
else
find . -name "*.md" -print0 | xargs -0 sed -i 's/```{mermaid}/```mermaid/g'
find . -name "*.ipynb" -print0 | xargs -0 sed -i 's/```{mermaid}/```mermaid/g'
fi
find _build -name "*.ipynb" -print0 | xargs -0 --no-run-if-empty grep -E "ImportError|KeyboardInterrupt|AttributeError|ModuleNotFoundError|NameError" || true
NUM=$(find _build -name "*.ipynb" -print0 | xargs -0 --no-run-if-empty grep -E "ImportError|KeyboardInterrupt|AttributeError|ModuleNotFoundError|NameError" | wc -l)
exit ${NUM}