Fix: CSIT documentation auto generation
[csit.git] / resources / tools / doc_gen / run_doc.sh
1 #!/bin/bash
2
3 WORKING_DIR='tmp'
4 BUILD_DIR='_build'
5
6 # Clean-up when finished:
7 trap 'rm -rf ${WORKING_DIR}; exit' EXIT
8 trap 'rm -rf ${WORKING_DIR}; exit' ERR
9
10 # Remove the old build:
11 rm -rf ${BUILD_DIR} || true
12 rm -rf ${WORKING_DIR} || true
13
14 # Create working directories
15 mkdir ${BUILD_DIR}
16 mkdir --parents ${WORKING_DIR}/resources/libraries/python/
17 mkdir --parents ${WORKING_DIR}/resources/libraries/robot/
18 mkdir --parents ${WORKING_DIR}/tests/
19
20 # Copy the Sphinx source files:
21 cp -r src/* ${WORKING_DIR}/
22
23 # Copy the source files to be processed:
24 rsync -a --include '*/' --include '*.py' --exclude '*' ../../../resources/libraries/python/ ${WORKING_DIR}/resources/libraries/python/
25 cp ../../../resources/__init__.py ${WORKING_DIR}/resources/
26 cp ../../../resources/libraries/__init__.py ${WORKING_DIR}/resources/libraries/
27 rsync -a --include '*/' --include '*.robot' --exclude '*' ../../../resources/libraries/robot/ ${WORKING_DIR}/resources/libraries/robot/
28 rsync -a --include '*/' --include '*.robot' --exclude '*' ../../../tests/ ${WORKING_DIR}/tests/
29
30 # Create virtual environment:
31 virtualenv ${WORKING_DIR}/env
32 . ${WORKING_DIR}/env/bin/activate
33
34 # Install CSIT requirements:
35 pip install -r ../../../requirements.txt
36 # Install Sphinx:
37 pip install -r ${WORKING_DIR}/requirements.txt
38
39 export PYTHONPATH=`pwd`
40
41 # Generate rst files:
42 ./gen_rst.py
43
44 # Remove all rst files from ./${WORKING_DIR}/env directory - we do not need them
45 find ./${WORKING_DIR}/env -type f -name '*.rst' | xargs rm -f
46
47 # Generate the documentation:
48 sphinx-build -v -b html ${WORKING_DIR} ${BUILD_DIR}/
49
50 find . -type d -name 'env' | xargs rm -rf
51
52 echo Creating csit.doc.tar.gz ...
53 tar -czvf ./csit.docs.tar.gz ${BUILD_DIR}