Skip to content

Commit 73cd588

Browse files
committed
docs: Add manual build scripts and comprehensive local build documentation
- Add build_docs.bat and build_docs.sh for simple local builds - Create BUILD_DOCS_MANUAL.md for manual script method guide - Create LOCAL_DOCS_BUILD.md as overview comparing both methods - Update ACT_LOCAL_GITHUB_ACTIONS.md with link to overview - All methods clearly marked as optional, don't affect core practice features
1 parent be319e8 commit 73cd588

File tree

5 files changed

+692
-0
lines changed

5 files changed

+692
-0
lines changed

build_docs.bat

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
@echo off
2+
chcp 65001 >nul
3+
REM ============================================
4+
REM Build Documentation Locally
5+
REM Usage:
6+
REM build_docs.bat (build only)
7+
REM build_docs.bat --serve (build and serve locally)
8+
REM build_docs.bat --clean (clean build directory first)
9+
REM ============================================
10+
11+
set BASE_DIR=%~dp0
12+
set VENV_PYTHON=%BASE_DIR%leetcode\Scripts\python.exe
13+
14+
REM Check if virtual environment exists
15+
if not exist "%VENV_PYTHON%" (
16+
echo Error: Virtual environment not found!
17+
echo Please create it first:
18+
echo py -3.11 -m venv leetcode
19+
echo leetcode\Scripts\activate
20+
echo pip install -r requirements.txt
21+
exit /b 1
22+
)
23+
24+
REM Check if requirements are installed
25+
"%VENV_PYTHON%" -c "import mkdocs" >nul 2>&1
26+
if errorlevel 1 (
27+
echo Installing dependencies...
28+
"%VENV_PYTHON%" -m pip install -r requirements.txt
29+
if errorlevel 1 (
30+
echo Error: Failed to install dependencies
31+
exit /b 1
32+
)
33+
)
34+
35+
REM Clean build directory if requested
36+
if "%~1"=="--clean" (
37+
echo Cleaning build directory...
38+
if exist "%BASE_DIR%site" (
39+
rmdir /s /q "%BASE_DIR%site"
40+
)
41+
shift
42+
)
43+
44+
echo.
45+
echo ============================================
46+
echo Building Documentation
47+
echo ============================================
48+
echo.
49+
50+
REM Step 1: Generate Mind Maps (Markdown)
51+
echo [1/4] Generating mind maps (Markdown)...
52+
"%VENV_PYTHON%" tools/generate_mindmaps.py
53+
if errorlevel 1 (
54+
echo Error: Failed to generate mind maps
55+
exit /b 1
56+
)
57+
58+
REM Step 2: Generate Mind Maps (HTML)
59+
echo [2/4] Generating mind maps (HTML)...
60+
"%VENV_PYTHON%" tools/generate_mindmaps.py --html
61+
if errorlevel 1 (
62+
echo Error: Failed to generate HTML mind maps
63+
exit /b 1
64+
)
65+
66+
REM Step 3: Build MkDocs site
67+
echo [3/4] Building MkDocs site...
68+
"%VENV_PYTHON%" -m mkdocs build
69+
if errorlevel 1 (
70+
echo Error: Failed to build MkDocs site
71+
exit /b 1
72+
)
73+
74+
REM Step 4: Copy mind map HTML files
75+
echo [4/4] Copying mind map HTML files...
76+
if exist "%BASE_DIR%docs\pages\mindmaps" (
77+
xcopy /E /I /Y "%BASE_DIR%docs\pages\mindmaps" "%BASE_DIR%site\pages\mindmaps" >nul
78+
)
79+
if exist "%BASE_DIR%docs\pages\assets" (
80+
xcopy /E /I /Y "%BASE_DIR%docs\pages\assets" "%BASE_DIR%site\pages\assets" >nul 2>nul
81+
)
82+
83+
echo.
84+
echo ============================================
85+
echo Build Complete!
86+
echo ============================================
87+
echo.
88+
echo Output directory: %BASE_DIR%site
89+
echo.
90+
91+
REM Serve locally if requested
92+
if "%~1"=="--serve" (
93+
echo Starting local server...
94+
echo Visit http://127.0.0.1:8000
95+
echo Press Ctrl+C to stop
96+
echo.
97+
"%VENV_PYTHON%" -m mkdocs serve
98+
)
99+

build_docs.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash
2+
# ============================================
3+
# Build Documentation Locally
4+
# Usage:
5+
# ./build_docs.sh (build only)
6+
# ./build_docs.sh --serve (build and serve locally)
7+
# ./build_docs.sh --clean (clean build directory first)
8+
# ============================================
9+
10+
# Get the directory where the script is located
11+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
VENV_PYTHON="${SCRIPT_DIR}/leetcode/bin/python"
13+
14+
# Check if virtual environment exists
15+
if [ ! -f "$VENV_PYTHON" ]; then
16+
echo "Error: Virtual environment not found!"
17+
echo "Please create it first:"
18+
echo " python -m venv leetcode"
19+
echo " source leetcode/bin/activate"
20+
echo " pip install -r requirements.txt"
21+
exit 1
22+
fi
23+
24+
# Check if requirements are installed
25+
if ! "$VENV_PYTHON" -c "import mkdocs" 2>/dev/null; then
26+
echo "Installing dependencies..."
27+
"$VENV_PYTHON" -m pip install -r requirements.txt
28+
if [ $? -ne 0 ]; then
29+
echo "Error: Failed to install dependencies"
30+
exit 1
31+
fi
32+
fi
33+
34+
# Clean build directory if requested
35+
if [ "$1" = "--clean" ]; then
36+
echo "Cleaning build directory..."
37+
rm -rf "${SCRIPT_DIR}/site"
38+
shift
39+
fi
40+
41+
echo ""
42+
echo "============================================"
43+
echo "Building Documentation"
44+
echo "============================================"
45+
echo ""
46+
47+
# Step 1: Generate Mind Maps (Markdown)
48+
echo "[1/4] Generating mind maps (Markdown)..."
49+
"$VENV_PYTHON" tools/generate_mindmaps.py
50+
if [ $? -ne 0 ]; then
51+
echo "Error: Failed to generate mind maps"
52+
exit 1
53+
fi
54+
55+
# Step 2: Generate Mind Maps (HTML)
56+
echo "[2/4] Generating mind maps (HTML)..."
57+
"$VENV_PYTHON" tools/generate_mindmaps.py --html
58+
if [ $? -ne 0 ]; then
59+
echo "Error: Failed to generate HTML mind maps"
60+
exit 1
61+
fi
62+
63+
# Step 3: Build MkDocs site
64+
echo "[3/4] Building MkDocs site..."
65+
"$VENV_PYTHON" -m mkdocs build
66+
if [ $? -ne 0 ]; then
67+
echo "Error: Failed to build MkDocs site"
68+
exit 1
69+
fi
70+
71+
# Step 4: Copy mind map HTML files
72+
echo "[4/4] Copying mind map HTML files..."
73+
if [ -d "${SCRIPT_DIR}/docs/pages/mindmaps" ]; then
74+
cp -r "${SCRIPT_DIR}/docs/pages/mindmaps" "${SCRIPT_DIR}/site/pages/" 2>/dev/null || true
75+
fi
76+
if [ -d "${SCRIPT_DIR}/docs/pages/assets" ]; then
77+
cp -r "${SCRIPT_DIR}/docs/pages/assets" "${SCRIPT_DIR}/site/pages/" 2>/dev/null || true
78+
fi
79+
80+
echo ""
81+
echo "============================================"
82+
echo "Build Complete!"
83+
echo "============================================"
84+
echo ""
85+
echo "Output directory: ${SCRIPT_DIR}/site"
86+
echo ""
87+
88+
# Serve locally if requested
89+
if [ "$1" = "--serve" ]; then
90+
echo "Starting local server..."
91+
echo "Visit http://127.0.0.1:8000"
92+
echo "Press Ctrl+C to stop"
93+
echo ""
94+
"$VENV_PYTHON" -m mkdocs serve
95+
fi
96+

docs/ACT_LOCAL_GITHUB_ACTIONS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This guide shows you how to use `act` to run GitHub Actions workflows locally without pushing to GitHub.
44

5+
> 📖 **Looking for other options?** See [Local Documentation Build Options](LOCAL_DOCS_BUILD.md) for a comparison of all available methods, including a simpler manual script method that doesn't require Docker.
6+
57
> ⚠️ **Important: This is an Optional Feature**
68
>
79
> This documentation is **completely optional** and is intended for:

0 commit comments

Comments
 (0)