Skip to content

Commit

Permalink
KRKNWK-14501: Add Python/sphinx requiremnts file.
Browse files Browse the repository at this point in the history
Add also helper script build_doc_in_docker.sh which simplifies
documentation generation by using Python docker.
Nothing except docker is required.

Signed-off-by: Tomasz Tyzenhauz <[email protected]>
  • Loading branch information
totyz committed Jul 7, 2022
1 parent aa2663a commit eadb11f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
38 changes: 38 additions & 0 deletions doc/build_doc_in_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
#


# Script to build documentation in python3.10 docker (no need to install anything except docker which is able to run without sudo)
# The scripts pulls official python docker image, starts container and inside container
# installs required Python packages (from requirements-doc.txt) and execute sphinx-build tool.
# HTML documentation is generated to build/html folder

# How to install docker on Ubuntu:
# 1. https://docs.docker.com/engine/install/ubuntu:
# 2. Run docker without sudo:
# 2.1. Issue command: sudo groupadd docker && sudo usermod -aG docker $USER
# 2.2. Log out and log back to activate the group membership in Linux or you can run: newgrp docker

function err_trap () {
echo "$0: line $1: exit status of last command: $2"
exit 1
}
set -E
trap 'err_trap ${LINENO} ${$?}' ERR

DOCKER=python:3.10

if [ $# -eq 0 ]; then
echo "Docker $DOCKER executing"
docker run -it --rm -e USER_ID=$(id -u) -e GRP_ID=$(id -g) -v "$(pwd)":/work -v "$(pwd)"/build_doc_in_docker.sh:/run.sh "${DOCKER}" /run.sh "RUN_IN_DOCKER"
echo "Docker exited"
elif [ $# -eq 1 ]; then
cd /work
pip install -r requirements-doc.txt
sphinx-build -M html . build
chown -R $USER_ID:$GRP_ID build
fi
20 changes: 20 additions & 0 deletions doc/requirements-doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Tested as OK with Python 3.8, 3.9, 3.10
breathe==4.30.0
Jinja2==2.11.3
MarkupSafe==1.1.1
Pygments==2.9.0
PyYAML==5.4.1
sphinx==4.3.0
sphinx-ncs-theme==0.6.2
sphinx-rtd-theme==0.5.2
sphinx-tabs==3.1.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp>=2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-mscgen==0.6
sphinxcontrib-plantuml==0.21
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml>=1.1.5
sphinxcontrib-svg2pdfconverter==1.1.1
sphinxcontrib-websupport==1.2.2

0 comments on commit eadb11f

Please sign in to comment.