-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathbuild_docs.sh
More file actions
executable file
·80 lines (69 loc) · 2.13 KB
/
build_docs.sh
File metadata and controls
executable file
·80 lines (69 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
# Description:
# This script builds documentation for the Python cuvslam package.
# It generates HTML documentation using Sphinx.
# It requires the following Python packages to be installed
# in the current Python environment:
# - sphinx
# - sphinx-rtd-theme
# It also requires the Python cuvslam package to be installed.
#
# Usage:
# ./build_docs.sh --build_dir=BUILD_DIR --src_dir=SRC_DIR
#
# Arguments:
# --build_dir: CMake build directory
# --src_dir: Source directory
set -e # Exit immediately if a command exits with a non-zero status
# Default values
BUILD_DIR=""
SRC_DIR=""
# Parse named arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--build_dir=*)
BUILD_DIR="${1#*=}"
;;
--src_dir=*)
SRC_DIR="${1#*=}"
;;
*)
echo "Error: Unknown argument: $1"
echo "Usage: $0 --build_dir=BUILD_DIR --src_dir=SRC_DIR"
exit 1
;;
esac
shift
done
# Check if required arguments are provided
if [ -z "$BUILD_DIR" ] || [ -z "$SRC_DIR" ]; then
echo "Error: Both --build_dir and --src_dir are required"
echo "Usage: $0 --build_dir=BUILD_DIR --src_dir=SRC_DIR"
exit 1
fi
# Check if directories exist
if [ ! -d "$BUILD_DIR" ]; then
echo "Error: Build directory '$BUILD_DIR' does not exist."
exit 1
fi
if [ ! -d "$SRC_DIR" ]; then
echo "Error: Source directory '$SRC_DIR' does not exist."
exit 1
fi
# Check if required Python packages are installed
if ! python3 -c "import sphinx, sphinx_rtd_theme" 2>/dev/null; then
echo "Error: Required Python packages (sphinx, sphinx-rtd-theme) not found."
echo "Please install them, e.g. using: pip install --user sphinx sphinx-rtd-theme"
exit 1
fi
# Check that Python cuvslam package is installed
python3 -c "import cuvslam" 2>/dev/null || {
echo "Error: Python cuvslam package is not installed in the current Python environment."
exit 1
}
# Create documentation directory in build directory
DOCS_BUILD_DIR="$BUILD_DIR/python_docs"
mkdir -p "$DOCS_BUILD_DIR"
# Build documentation
sphinx-build -b html "$SRC_DIR" "$DOCS_BUILD_DIR/html"
echo "You can open $(realpath "$DOCS_BUILD_DIR/html/index.html") in your browser to view documentation."