-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_docs.sh
More file actions
71 lines (55 loc) · 2.27 KB
/
Copy pathbuild_docs.sh
File metadata and controls
71 lines (55 loc) · 2.27 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
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
# Get the absolute path to the repository root
REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd)
# Define paths
TEMP_DIR="$REPO_ROOT/temp_repos"
DOCS_DIR="$REPO_ROOT/docs"
DOCS_SOURCE="$REPO_ROOT/sphinx_source"
LIBS_SOURCE="$DOCS_SOURCE/libs"
# Clean up previous build and temp directories
echo "Cleaning previous build..."
rm -rf "$DOCS_DIR/"*.html "$DOCS_DIR/"*.js "$DOCS_DIR/"*.css "$DOCS_DIR/_static" "$DOCS_DIR/_sources" "$TEMP_DIR" "$LIBS_SOURCE"
# Create necessary directories
mkdir -p "$TEMP_DIR" "$LIBS_SOURCE"
# List of repositories to clone and document
declare -A REPOSITORIES=(
["file-processing"]="https://github.com/hc-sc-ocdo-bdpd/file-processing.git"
["file-processing-ocr"]="https://github.com/hc-sc-ocdo-bdpd/file-processing-ocr.git"
["file-processing-transcription"]="https://github.com/hc-sc-ocdo-bdpd/file-processing-transcription.git"
["file-processing-analytics"]="https://github.com/hc-sc-ocdo-bdpd/file-processing-analytics.git"
["file-processing-test-data"]="https://github.com/hc-sc-ocdo-bdpd/file-processing-test-data.git"
)
# Clone the repositories
echo "Cloning repositories..."
for LIB_NAME in "${!REPOSITORIES[@]}"; do
REPO_URL="${REPOSITORIES[$LIB_NAME]}"
git clone --depth 1 "$REPO_URL" "$TEMP_DIR/$LIB_NAME"
done
# Function to generate API documentation for a library
generate_docs() {
local LIB_NAME=$1
local SOURCE_DIR="$TEMP_DIR/$LIB_NAME"
local OUTPUT_DIR="$LIBS_SOURCE/$LIB_NAME"
echo "Generating docs for $LIB_NAME..."
# Create output directory
mkdir -p "$OUTPUT_DIR"
# Generate API docs, excluding certain files and directories
sphinx-apidoc -o "$OUTPUT_DIR" "$SOURCE_DIR" "setup.py" "tests/*" "*/tests/*" "**/tests/*" --force
if [ $? -ne 0 ]; then
echo "Error: sphinx-apidoc failed for $LIB_NAME"
exit 1
fi
}
# Generate API documentation for each library
for LIB_NAME in "${!REPOSITORIES[@]}"; do
generate_docs "$LIB_NAME"
done
# Build the documentation using Sphinx
echo "Building HTML documentation with Sphinx..."
python -m sphinx -b html "$DOCS_SOURCE" "$DOCS_DIR"
# Clean up temporary files
echo "Cleaning up temporary files..."
rm -rf "$TEMP_DIR"
echo "Documentation build completed successfully!"