Skip to content

Commit 63f2811

Browse files
fsecada01claude
andcommitted
docs: Add documentation build script for CI/CD
- Create docs/make.py to generate API reference with pdoc - Script preserves custom landing page, use-cases, and recipes - Fixes GitHub Actions workflow failure (missing docs/make.py) - Uses ASCII characters for cross-platform compatibility - Mark script as executable for CI/CD Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 8d09e65 commit 63f2811

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

docs/make.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Documentation build script for sqlmodel-crud-utils.
4+
5+
This script generates the API reference documentation using pdoc
6+
while preserving the custom landing page, use-cases, and recipes pages.
7+
"""
8+
9+
import shutil
10+
import subprocess
11+
import sys
12+
from pathlib import Path
13+
14+
# Get the project root (parent of docs/)
15+
DOCS_DIR = Path(__file__).parent
16+
PROJECT_ROOT = DOCS_DIR.parent
17+
18+
# Files to preserve (our custom documentation pages)
19+
PRESERVE_FILES = [
20+
"index.html",
21+
"use-cases.html",
22+
"recipes.html",
23+
]
24+
25+
26+
def main() -> int:
27+
"""Build the documentation."""
28+
print("Building sqlmodel-crud-utils documentation...")
29+
30+
# Backup custom files
31+
print("\n1. Backing up custom documentation pages...")
32+
backup_dir = DOCS_DIR / ".backup"
33+
backup_dir.mkdir(exist_ok=True)
34+
35+
for filename in PRESERVE_FILES:
36+
file_path = DOCS_DIR / filename
37+
if file_path.exists():
38+
backup_path = backup_dir / filename
39+
shutil.copy2(file_path, backup_path)
40+
print(f" [OK] Backed up {filename}")
41+
42+
# Generate API documentation with pdoc
43+
print("\n2. Generating API reference with pdoc...")
44+
try:
45+
subprocess.run(
46+
[
47+
sys.executable,
48+
"-m",
49+
"pdoc",
50+
"sqlmodel_crud_utils",
51+
"-o",
52+
str(DOCS_DIR),
53+
],
54+
check=True,
55+
cwd=PROJECT_ROOT,
56+
)
57+
print(" [OK] API documentation generated")
58+
except subprocess.CalledProcessError as e:
59+
print(f" [ERROR] Failed to generate API documentation: {e}")
60+
return 1
61+
62+
# Restore custom files
63+
print("\n3. Restoring custom documentation pages...")
64+
for filename in PRESERVE_FILES:
65+
backup_path = backup_dir / filename
66+
if backup_path.exists():
67+
file_path = DOCS_DIR / filename
68+
shutil.copy2(backup_path, file_path)
69+
print(f" [OK] Restored {filename}")
70+
71+
# Cleanup backup directory
72+
shutil.rmtree(backup_dir)
73+
print("\n[OK] Documentation build complete!")
74+
75+
return 0
76+
77+
78+
if __name__ == "__main__":
79+
sys.exit(main())

0 commit comments

Comments
 (0)