diff --git a/Dockerfile b/Dockerfile index c2b9c094661986ba1720ff800adcb00b81f1f83f..61242dbd077b3e0051245ef6e9e55fd7bd2bceeb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,12 +30,17 @@ RUN python3 -m pip install --upgrade pip RUN python3 -m pip install cython numpy opencv-python pybind11 build # Venv for python-build RUN apt-get install -y python3-venv + +# Sphinx for documentation +RUN python3 -m pip install sphinx sphinx_rtd_theme + # Create paths RUN mkdir -p /build && mkdir -p /opt/scripts/ RUN mkdir -p $src_path + WORKDIR $src_path # Copy the necessary scripts in COPY ./Scripts/* /opt/scripts/ - +RUN chmod +x /opt/scripts/* ENTRYPOINT [ "/opt/scripts/entrypoint.sh" ] # ENTRYPOINT [ "./sandbox_docker-builder/entrypoint.sh" ] \ No newline at end of file diff --git a/Makefile b/Makefile index 8702435fcbc1eafa9e750536ed0b147548d6fb81..b6938f4bd2e68a2adaf50915e6b7dcc566fe9c97 100644 --- a/Makefile +++ b/Makefile @@ -11,5 +11,8 @@ create: docker-compose.yml Dockerfile build: docker-compose.yml $(DCR) $(CONTAINER_NAME) build +docs: docker-compose.yml + $(DCR) $(CONTAINER_NAME) docs html + clean: docker-compose.yml $(DCR) $(CONTAINER_NAME) clean \ No newline at end of file diff --git a/README.md b/README.md index 53eaf04643f92dc6b27b276c3bac8a755bcdcb38..df304d0fde29295e39530ee74d2b78d88d844250 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ The provided makefile allow simple manipulation of the docker to build, clean an | create | `make create` | Build the docker container | | build (default) | `make` or `make build` | Build everything | | clean | `make clean` | Cleanup | +| docs | `make docs` | Build the documentation for the python wrapper (Lib and wrapper must be built beforehand) | ## Docker container @@ -72,6 +73,7 @@ The following arguments are available : | Arg | Description | |-- |--| | `build [lib] [wrapper]` | Will build the indicated component. `wrapper` should be built after `lib`. If none provided, build everything. | +| `docs [mode] [opts]` | Build the wrapper documentation using sphinx-build. Everything must be already built. You may override `mode` (default to `html`.). You may override the sphinx-build options by passing `opts` which are relayed to the sphinx-build command. To provide `opts`, `mode` must be set. | | `clean [lib] [wrapper]` | Will cleanup the build directories. If no component provided, clean everything. | | `bash` or `s` | Execute a bash terminal inside the docker. May or may not be useful. | | `exec CMD [ARGS]` or `c [CMD] [ARGS]` | Execute the command `CMD` with the arguments `ARGS` inside the docker. May or may not be useful. | \ No newline at end of file diff --git a/Scripts/entrypoint.sh b/Scripts/entrypoint.sh index 27b25d78f8f26f47c6785ddd004ca355f81eaa36..007faa8690d8dd9443db1662780f3a84a994a879 100644 --- a/Scripts/entrypoint.sh +++ b/Scripts/entrypoint.sh @@ -81,6 +81,29 @@ function build_all() { make_target $SBOX_PYWR } +function make_python_docs() { + export LD_LIBRARY_PATH=$SBOX_LIB/build/ + local MODE='html' + if [ ! -z $1 ]; then + MODE=$1 + shift + fi + if [ ! -z $1 ]; then + SOPT="$@" + echo $SOPT + fi + echo -e "${GRN}Running sphinx-build in html mode.${NC}" + cd $SBOX_PYWR/docs/ && SPHINXOPTS=$SOPT make $MODE +} + +function clean_python_doc() { + cd $SBOX_PYWR/docs/ && make clean && rm -rf ./_build +} + +function build_doc() { + clean_python_doc + make_python_docs $@ +} ## Main entry of script. Check for arguments if [ $# -gt 0 ]; then @@ -143,11 +166,17 @@ if [ $# -gt 0 ]; then elif [ $1 = "test" ]; then shift /opt/scripts/test-pypackage.sh + exit 0 + elif [ $1 = "docs" ]; then + shift + build_doc $@ + exit 0 elif [ $1 = "bt" ]; then shift build_all copy_artifacts /opt/scripts/test-pypackage.sh + exit 0 fi exit 1 fi