|
1 | 1 | #!/bin/bash |
2 | | -# Locally build the documentation and display it in a webserver. |
3 | 2 |
|
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