Skip to content

Commit 1fbbade

Browse files
authored
Add docker image that allows to run docs in development mode (luxonis#157)
* add docker image * change to ubuntu:20.04 base image * make docs build work * linting * organize the docker files and optimize update script * fix docker build & update * update README.md, add building instuctions for docs * remove unneeded flag * Update documentation and speed up the updates
1 parent 75b8add commit 1fbbade

6 files changed

Lines changed: 83 additions & 2 deletions

File tree

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,46 @@ Python bindings for C++ depthai-core library
1010

1111
Documentation is available over at [Luxonis DepthAI API](https://docs.luxonis.com/projects/api/en/latest/)
1212

13+
### Building documentation
14+
15+
- **Using [Docker](https://docs.docker.com/) (with [Docker Compose](https://docs.docker.com/compose/install/))**
16+
17+
```
18+
cd docs
19+
docker-compose build
20+
docker-compose up
21+
```
22+
23+
Then open [http://localhost:8000](http://localhost:8000).
24+
25+
This docker container will watch changes in the `docs/source` directory and rebuild the docs automatically
26+
27+
- **Linux**
28+
29+
First, please install the required [dependencies](#Dependencies)
30+
31+
Then run the following commands to build the docs website
32+
33+
```
34+
python3 -m pip install -U pip
35+
python3 -m pip install -r docs/requirements.txt
36+
cmake -S . -B build -D DEPTHAI_BUILD_DOCS=ON -D DEPTHAI_PYTHON_BUILD_DOCS=ON
37+
cmake --build build --parallel --target sphinx
38+
python3 -m http.server --bind 0.0.0.0 8000 --directory build/docs/sphinx
39+
```
40+
41+
Then open [http://localhost:8000](http://localhost:8000).
42+
43+
This will build documentation based on current sources, so if some new changes will be made, run this command
44+
in a new terminal window to update the website source
45+
46+
```
47+
cmake --build build --parallel --target sphinx
48+
```
49+
50+
Then refresh your page - it should load the updated website that was just built
51+
52+
1353
## Installation
1454
1555
Prebuilt wheels are available in [Luxonis repository](https://artifacts.luxonis.com/artifactory/luxonis-python-snapshot-local/)

docs/docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
docs:
3+
build:
4+
dockerfile: docs/docker/dev.dockerfile
5+
context: ..
6+
volumes:
7+
- ./:/app/docs
8+
ports:
9+
- 8000:8000

docs/docker/dev.dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM ubuntu:20.04
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
RUN apt-get update && apt-get install -y libusb-1.0-0-dev clang python3-opencv python3-pip clang-11 doxygen cmake git
5+
RUN python3 -m pip install -U pip numpy when-changed
6+
7+
ENV CC clang-10
8+
ENV CXX clang++-10
9+
WORKDIR /app
10+
ADD docs/requirements.txt docs/requirements.txt
11+
RUN python3 -m pip install -r docs/requirements.txt
12+
ADD . .
13+
CMD docs/docker/docker_run.sh

docs/docker/docker_run.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cmake -S . -B build -D DEPTHAI_BUILD_DOCS=ON -D DEPTHAI_PYTHON_BUILD_DOCS=ON
6+
7+
./docs/docker/update_docs.sh
8+
9+
when-changed -r docs/source -c "bash /app/docs/docker/update_docs.sh" &
10+
11+
python3 -m http.server --bind 0.0.0.0 8000 --directory build/docs/sphinx

docs/docker/update_docs.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cmake --build build --parallel --target sphinx
6+
7+
# fix missing index.css file
8+
cp /app/docs/source/_static/css/* /app/build/docs/sphinx/_static/css

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Sphinx==3.4.3
22
sphinx-tabs==1.3.0
33
sphinx-rtd-theme==0.5.0
4-
git+git://github.com/VanDavv/rtd-redirects.git@3e7333898acad533b37c9de426f1f2ef258d756b
4+
git+https://github.com/VanDavv/rtd-redirects.git@3e7333898acad533b37c9de426f1f2ef258d756b
55
breathe==4.26.0
6-
git+git://github.com/luxonis/pybind11_mkdoc.git@master
6+
git+https://github.com/luxonis/pybind11_mkdoc.git@master
77
Sphinx-Substitution-Extensions==2020.9.30.0
88
sphinx-autopackagesummary==1.3
99
autodocsumm==0.2.2

0 commit comments

Comments
 (0)