Skip to content

Commit fe6ae56

Browse files
committed
refactor: Move build_docs scripts to scripts/ directory
- Create scripts/ directory for utility scripts - Move build_docs.bat/sh from tools/ to scripts/ - Update all documentation paths to scripts/build_docs.* - Add scripts/README.md for directory documentation - Remove build_docs references from tools/README.md - Follows common project organization pattern
1 parent 73cd588 commit fe6ae56

File tree

5 files changed

+119
-39
lines changed

5 files changed

+119
-39
lines changed

docs/BUILD_DOCS_MANUAL.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ This guide shows you how to build documentation locally using simple batch/shell
4040

4141
```bash
4242
# Windows
43-
build_docs.bat
43+
scripts\build_docs.bat
4444

4545
# Linux/macOS
46-
./build_docs.sh
46+
./scripts/build_docs.sh
4747
```
4848

4949
**Build and preview locally:**
5050

5151
```bash
5252
# Windows
53-
build_docs.bat --serve
53+
scripts\build_docs.bat --serve
5454

5555
# Linux/macOS
56-
./build_docs.sh --serve
56+
./scripts/build_docs.sh --serve
5757
```
5858

5959
Then visit http://127.0.0.1:8000 in your browser.
@@ -85,10 +85,10 @@ Build the documentation site:
8585

8686
```bash
8787
# Windows
88-
build_docs.bat
88+
scripts\build_docs.bat
8989

9090
# Linux/macOS
91-
./build_docs.sh
91+
./scripts/build_docs.sh
9292
```
9393

9494
**Output:** The built site will be in the `site/` directory.
@@ -99,10 +99,10 @@ Build and start a local server to preview:
9999

100100
```bash
101101
# Windows
102-
build_docs.bat --serve
102+
scripts\build_docs.bat --serve
103103

104104
# Linux/macOS
105-
./build_docs.sh --serve
105+
./scripts/build_docs.sh --serve
106106
```
107107

108108
Then open http://127.0.0.1:8000 in your browser.
@@ -115,18 +115,18 @@ Remove the existing `site/` directory before building:
115115

116116
```bash
117117
# Windows
118-
build_docs.bat --clean
118+
scripts\build_docs.bat --clean
119119

120120
# Linux/macOS
121-
./build_docs.sh --clean
121+
./scripts/build_docs.sh --clean
122122
```
123123

124124
### Combined Options
125125

126126
```bash
127127
# Clean build and serve
128-
build_docs.bat --clean --serve
129-
./build_docs.sh --clean --serve
128+
scripts\build_docs.bat --clean --serve
129+
./scripts/build_docs.sh --clean --serve
130130
```
131131

132132
---

docs/LOCAL_DOCS_BUILD.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ This guide provides an overview of different methods to build documentation loca
2929
**Quick Start:**
3030
```bash
3131
# Windows
32-
build_docs.bat --serve
32+
scripts\build_docs.bat --serve
3333

3434
# Linux/macOS
35-
./build_docs.sh --serve
35+
./scripts/build_docs.sh --serve
3636
```
3737

3838
📖 **[Full Guide →](BUILD_DOCS_MANUAL.md)**
@@ -98,8 +98,8 @@ act -P ubuntu-latest=catthehacker/ubuntu:act-latest -j build
9898
```bash
9999
# 1. No installation needed (just use existing Python venv)
100100
# 2. Run script
101-
build_docs.bat --serve # Windows
102-
./build_docs.sh --serve # Linux/macOS
101+
scripts\build_docs.bat --serve # Windows
102+
./scripts/build_docs.sh --serve # Linux/macOS
103103
# 3. Done! Visit http://127.0.0.1:8000
104104
```
105105

scripts/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Scripts Directory
2+
3+
This directory contains utility scripts for project maintenance and development.
4+
5+
> ⚠️ **Note**: These scripts are **optional** and intended for project maintainers and contributors. Core LeetCode practice functionality does NOT require these scripts.
6+
7+
---
8+
9+
## 📋 Available Scripts
10+
11+
### Documentation Build Scripts
12+
13+
| Script | Purpose | Usage |
14+
|:-------|:--------|:------|
15+
| `build_docs.bat` / `build_docs.sh` | Build documentation site locally | `scripts\build_docs.bat --serve` (Windows)<br>`./scripts/build_docs.sh --serve` (Linux/macOS) |
16+
17+
**Features:**
18+
- ✅ No Docker required
19+
- ✅ No external tools required
20+
- ✅ Simple one-command build
21+
- ✅ Fast execution
22+
23+
📖 **[Full Documentation →](../docs/BUILD_DOCS_MANUAL.md)**
24+
25+
---
26+
27+
## 🎯 Usage
28+
29+
### Build Documentation
30+
31+
```bash
32+
# Windows
33+
scripts\build_docs.bat
34+
35+
# Linux/macOS
36+
./scripts/build_docs.sh
37+
```
38+
39+
### Build and Preview Locally
40+
41+
```bash
42+
# Windows
43+
scripts\build_docs.bat --serve
44+
45+
# Linux/macOS
46+
./scripts/build_docs.sh --serve
47+
```
48+
49+
Then visit http://127.0.0.1:8000 in your browser.
50+
51+
---
52+
53+
## 📚 Related Documentation
54+
55+
- [Local Documentation Build Options](../docs/LOCAL_DOCS_BUILD.md) - Overview of all local build methods
56+
- [Manual Build Guide](../docs/BUILD_DOCS_MANUAL.md) - Complete guide for manual script method
57+
- [Act Guide](../docs/ACT_LOCAL_GITHUB_ACTIONS.md) - Using act to simulate CI/CD
58+
59+
---
60+
61+
## 🔄 Future Scripts
62+
63+
This directory may contain additional utility scripts in the future:
64+
- Deployment scripts
65+
- Maintenance scripts
66+
- Development helper scripts
67+
68+
All scripts will follow the same naming convention: `script_name.bat` (Windows) and `script_name.sh` (Linux/macOS).
69+

build_docs.bat renamed to scripts/build_docs.bat

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ chcp 65001 >nul
33
REM ============================================
44
REM Build Documentation Locally
55
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)
6+
REM scripts\build_docs.bat (build only)
7+
REM scripts\build_docs.bat --serve (build and serve locally)
8+
REM scripts\build_docs.bat --clean (clean build directory first)
99
REM ============================================
1010

11-
set BASE_DIR=%~dp0
12-
set VENV_PYTHON=%BASE_DIR%leetcode\Scripts\python.exe
11+
REM Get project root directory (parent of scripts/)
12+
set SCRIPT_DIR=%~dp0
13+
set PROJECT_ROOT=%SCRIPT_DIR%..
14+
set VENV_PYTHON=%PROJECT_ROOT%\leetcode\Scripts\python.exe
1315

1416
REM Check if virtual environment exists
1517
if not exist "%VENV_PYTHON%" (
@@ -25,18 +27,22 @@ REM Check if requirements are installed
2527
"%VENV_PYTHON%" -c "import mkdocs" >nul 2>&1
2628
if errorlevel 1 (
2729
echo Installing dependencies...
30+
cd /d "%PROJECT_ROOT%"
2831
"%VENV_PYTHON%" -m pip install -r requirements.txt
2932
if errorlevel 1 (
3033
echo Error: Failed to install dependencies
3134
exit /b 1
3235
)
3336
)
3437

38+
REM Change to project root directory
39+
cd /d "%PROJECT_ROOT%"
40+
3541
REM Clean build directory if requested
3642
if "%~1"=="--clean" (
3743
echo Cleaning build directory...
38-
if exist "%BASE_DIR%site" (
39-
rmdir /s /q "%BASE_DIR%site"
44+
if exist "%PROJECT_ROOT%\site" (
45+
rmdir /s /q "%PROJECT_ROOT%\site"
4046
)
4147
shift
4248
)
@@ -73,19 +79,19 @@ if errorlevel 1 (
7379

7480
REM Step 4: Copy mind map HTML files
7581
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
82+
if exist "%PROJECT_ROOT%\docs\pages\mindmaps" (
83+
xcopy /E /I /Y "%PROJECT_ROOT%\docs\pages\mindmaps" "%PROJECT_ROOT%\site\pages\mindmaps" >nul
7884
)
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
85+
if exist "%PROJECT_ROOT%\docs\pages\assets" (
86+
xcopy /E /I /Y "%PROJECT_ROOT%\docs\pages\assets" "%PROJECT_ROOT%\site\pages\assets" >nul 2>nul
8187
)
8288

8389
echo.
8490
echo ============================================
8591
echo Build Complete!
8692
echo ============================================
8793
echo.
88-
echo Output directory: %BASE_DIR%site
94+
echo Output directory: %PROJECT_ROOT%\site
8995
echo.
9096

9197
REM Serve locally if requested

build_docs.sh renamed to scripts/build_docs.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
# ============================================
33
# Build Documentation Locally
44
# 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)
5+
# ./scripts/build_docs.sh (build only)
6+
# ./scripts/build_docs.sh --serve (build and serve locally)
7+
# ./scripts/build_docs.sh --clean (clean build directory first)
88
# ============================================
99

10-
# Get the directory where the script is located
10+
# Get script directory and project root
1111
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12-
VENV_PYTHON="${SCRIPT_DIR}/leetcode/bin/python"
12+
PROJECT_ROOT="$SCRIPT_DIR/.."
13+
VENV_PYTHON="$PROJECT_ROOT/leetcode/bin/python"
1314

1415
# Check if virtual environment exists
1516
if [ ! -f "$VENV_PYTHON" ]; then
@@ -24,17 +25,21 @@ fi
2425
# Check if requirements are installed
2526
if ! "$VENV_PYTHON" -c "import mkdocs" 2>/dev/null; then
2627
echo "Installing dependencies..."
28+
cd "$PROJECT_ROOT"
2729
"$VENV_PYTHON" -m pip install -r requirements.txt
2830
if [ $? -ne 0 ]; then
2931
echo "Error: Failed to install dependencies"
3032
exit 1
3133
fi
3234
fi
3335

36+
# Change to project root directory
37+
cd "$PROJECT_ROOT"
38+
3439
# Clean build directory if requested
3540
if [ "$1" = "--clean" ]; then
3641
echo "Cleaning build directory..."
37-
rm -rf "${SCRIPT_DIR}/site"
42+
rm -rf "$PROJECT_ROOT/site"
3843
shift
3944
fi
4045

@@ -70,19 +75,19 @@ fi
7075

7176
# Step 4: Copy mind map HTML files
7277
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
78+
if [ -d "$PROJECT_ROOT/docs/pages/mindmaps" ]; then
79+
cp -r "$PROJECT_ROOT/docs/pages/mindmaps" "$PROJECT_ROOT/site/pages/" 2>/dev/null || true
7580
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
81+
if [ -d "$PROJECT_ROOT/docs/pages/assets" ]; then
82+
cp -r "$PROJECT_ROOT/docs/pages/assets" "$PROJECT_ROOT/site/pages/" 2>/dev/null || true
7883
fi
7984

8085
echo ""
8186
echo "============================================"
8287
echo "Build Complete!"
8388
echo "============================================"
8489
echo ""
85-
echo "Output directory: ${SCRIPT_DIR}/site"
90+
echo "Output directory: $PROJECT_ROOT/site"
8691
echo ""
8792

8893
# Serve locally if requested

0 commit comments

Comments
 (0)