-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocs.sh
More file actions
executable file
·111 lines (99 loc) · 2.62 KB
/
Copy pathdocs.sh
File metadata and controls
executable file
·111 lines (99 loc) · 2.62 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
# Documentation build and serve script for vibegui
set -e
# Change to docs directory
cd "$(dirname "$0")/docs"
# Function to show usage
show_help() {
echo "Usage: $0 [COMMAND]"
echo ""
echo "Commands:"
echo " build Build the documentation (default)"
echo " clean Clean the build directory"
echo " serve Build and serve the documentation with live reload"
echo " open Build and open the documentation in browser"
echo " help Show this help message"
echo ""
echo "Examples:"
echo " $0 build # Build the documentation"
echo " $0 serve # Serve with live reload on http://127.0.0.1:8000"
echo " $0 open # Build and open in default browser"
}
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to build documentation
build_docs() {
echo "Building documentation..."
if command_exists make; then
make html
else
sphinx-build -b html . _build/html
fi
echo "Documentation built successfully!"
echo "Open file://$(pwd)/_build/html/index.html in your browser to view it."
}
# Function to clean build directory
clean_docs() {
echo "Cleaning documentation build directory..."
if command_exists make; then
make clean
else
rm -rf _build
fi
echo "Build directory cleaned!"
}
# Function to serve documentation with live reload
serve_docs() {
if ! command_exists sphinx-autobuild; then
echo "sphinx-autobuild not found."
fi
echo "Starting documentation server with live reload..."
echo "Documentation will be available at: http://127.0.0.1:8000"
echo "Press Ctrl+C to stop the server."
sphinx-autobuild . _build/html --host 127.0.0.1 --port 8000
}
# Function to build and open documentation
open_docs() {
build_docs
# Try to open in browser
local html_file="file://$(pwd)/_build/html/index.html"
if command_exists open; then
# macOS
open "$html_file"
elif command_exists xdg-open; then
# Linux
xdg-open "$html_file"
elif command_exists start; then
# Windows
start "$html_file"
else
echo "Could not automatically open browser."
echo "Please open: $html_file"
fi
}
# Main script logic
case "${1:-build}" in
build)
build_docs
;;
clean)
clean_docs
;;
serve)
serve_docs
;;
open)
open_docs
;;
help|--help|-h)
show_help
;;
*)
echo "Unknown command: $1"
echo ""
show_help
exit 1
;;
esac