forked from terrene-foundation/kailash-py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_docs.py
More file actions
executable file
·72 lines (56 loc) · 2.04 KB
/
build_docs.py
File metadata and controls
executable file
·72 lines (56 loc) · 2.04 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
#!/usr/bin/env python3
"""
Build documentation for GitHub Pages deployment.
This script builds the Sphinx documentation and prepares it for GitHub Pages.
"""
import os
import shutil
import subprocess
import sys
from pathlib import Path
def run_command(cmd, cwd=None):
"""Run a shell command and handle errors."""
print(f"Running: {' '.join(cmd)}")
result = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True)
if result.returncode != 0:
print(f"Error: {result.stderr}")
sys.exit(1)
return result.stdout
def main():
# Get paths
script_dir = Path(__file__).parent
docs_dir = script_dir
build_dir = docs_dir / "_build" / "html"
# Change to docs directory
os.chdir(docs_dir)
print("=== Building Sphinx Documentation ===")
# Install dependencies
print("\n1. Checking dependencies...")
try:
import importlib.util
if importlib.util.find_spec("sphinx") is None:
raise ImportError("Sphinx not found")
print(" ✓ Sphinx is installed")
except ImportError:
print(" Installing Sphinx and dependencies...")
run_command([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
# Clean previous builds
print("\n2. Cleaning previous builds...")
if build_dir.exists():
shutil.rmtree(build_dir)
print(" ✓ Cleaned _build directory")
# Build HTML documentation
print("\n3. Building HTML documentation...")
run_command(["make", "html"])
print(" ✓ Documentation built successfully")
# Create .nojekyll file for GitHub Pages
(build_dir / ".nojekyll").touch()
print(" ✓ Created .nojekyll file")
print("\n=== Build Complete! ===")
print(f"Documentation built in: {build_dir}")
print("\nTo deploy to GitHub Pages:")
print("1. Enable GitHub Pages in repository settings")
print("2. Use GitHub Actions workflow for automatic deployment")
print("3. Or manually copy _build/html contents to GitHub Pages branch")
if __name__ == "__main__":
main()