Skip to content

Commit f4a08b5

Browse files
committed
Finish build setup
1 parent cc5f3ef commit f4a08b5

File tree

4 files changed

+17
-95
lines changed

4 files changed

+17
-95
lines changed

build_docs.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This directory contains the documentation for CEBRA.
55
To build the docs, head to *the root folder of the repository* and run:
66

77
```bash
8-
./build_docs.sh
8+
./tools/build_docs.sh
99
```
1010

1111
This will build the docker container in [Dockerfile](Dockerfile) and run the `make docs` command from the root repo.

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def get_years(start_year=2021):
131131
# This pattern also affects html_static_path and html_extra_path.
132132
exclude_patterns = [
133133
"**/todo", "**/src", "cebra-figures/figures.rst", "cebra-figures/*.rst",
134-
"*/cebra-figures/*.rst", "*/demo_notebooks/README.rst"
134+
"*/cebra-figures/*.rst", "*/demo_notebooks/README.rst",
135135
"demo_notebooks/README.rst"
136136
]
137137

tools/build_docs.sh

Lines changed: 15 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,17 @@
11
#!/bin/bash
2-
# Locally build the documentation and display it in a webserver.
32

4-
set -xe
5-
6-
git_checkout_or_pull() {
7-
local repo=$1
8-
local target_dir=$2
9-
# TODO(stes): theoretically we could also auto-update the repo,
10-
# I commented this out for now to avoid interference with local
11-
# dev/changes
12-
#if [ -d "$target_dir" ]; then
13-
# cd "$target_dir"
14-
# git pull --ff-only origin main
15-
# cd -
16-
#else
17-
if [ ! -d "$target_dir" ]; then
18-
git clone "$repo" "$target_dir"
19-
fi
20-
}
21-
22-
checkout_cebra_figures() {
23-
git_checkout_or_pull [email protected]:AdaptiveMotorControlLab/cebra-figures.git docs/source/cebra-figures
24-
}
25-
26-
checkout_assets() {
27-
git_checkout_or_pull [email protected]:AdaptiveMotorControlLab/cebra-assets.git assets
28-
}
29-
30-
checkout_cebra_demos() {
31-
git_checkout_or_pull [email protected]:AdaptiveMotorControlLab/cebra-demos.git docs/source/demo_notebooks
32-
}
33-
34-
setup_python() {
35-
python -m pip install --upgrade pip setuptools wheel
36-
sudo apt-get install -y pandoc
37-
pip install torch --extra-index-url=https://download.pytorch.org/whl/cpu
38-
pip install '.[docs]'
39-
}
40-
41-
build_docs() {
42-
cp -r assets/* .
43-
export SPHINXOPTS="-W --keep-going -n"
44-
(cd docs && PYTHONPATH=.. make page)
45-
}
46-
47-
serve() {
48-
python -m http.server 8080 --b 0.0.0.0 -d docs/build/html
49-
}
50-
51-
main() {
52-
build_docs
53-
serve
54-
}
55-
56-
if [[ "$1" == "--build" ]]; then
57-
main
58-
fi
59-
60-
docker build -t cebra-docs -f - . << "EOF"
61-
FROM python:3.9
62-
RUN python -m pip install --upgrade pip setuptools wheel \
63-
&& apt-get update -y && apt-get install -y pandoc git
64-
RUN pip install torch --extra-index-url=https://download.pytorch.org/whl/cpu
65-
COPY dist/cebra-0.5.0-py3-none-any.whl .
66-
RUN pip install 'cebra-0.5.0-py3-none-any.whl[docs]'
67-
EOF
68-
69-
checkout_cebra_figures
70-
checkout_assets
71-
checkout_cebra_demos
72-
73-
docker run \
74-
-p 127.0.0.1:8080:8080 \
75-
-u $(id -u):$(id -g) \
76-
-v .:/app -w /app \
77-
--tmpfs /.config --tmpfs /.cache \
78-
-it cebra-docs \
79-
./tools/build_docs.sh --build
3+
docker build -t cebra-docs -f docs/Dockerfile .
4+
5+
docker run -u $(id -u):$(id -g) \
6+
-p 127.0.0.1:8000:8000 \
7+
-v $(pwd):/app \
8+
-v /tmp/.cache/pip:/.cache/pip \
9+
-v /tmp/.cache/sphinx:/.cache/sphinx \
10+
-v /tmp/.cache/matplotlib:/.cache/matplotlib \
11+
-v /tmp/.cache/fontconfig:/.cache/fontconfig \
12+
-e MPLCONFIGDIR=/tmp/.cache/matplotlib \
13+
-w /app \
14+
--env HOST=0.0.0.0 \
15+
--env PORT=8000 \
16+
-it cebra-docs \
17+
make docs

0 commit comments

Comments
 (0)