Skip to content

Commit 6a84644

Browse files
committed
feat: add interactive AI mind map generation to build scripts
- Add optional step to generate AI-powered mind maps in build_docs.bat/sh - Prompt user whether to generate AI mind maps (requires OPENAI_API_KEY) - Continue build even if AI generation fails - Update scripts/README.md with AI mind map feature documentation
1 parent 1f074c6 commit 6a84644

File tree

3 files changed

+60
-12
lines changed

3 files changed

+60
-12
lines changed

scripts/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ This directory contains utility scripts for project maintenance and development.
3333
- ✅ No external tools required
3434
- ✅ Simple one-command build
3535
- ✅ Fast execution
36+
- ✅ Interactive prompt for AI mind map generation (optional, requires OPENAI_API_KEY)
3637

3738
📖 **[Full Documentation →](../docs/BUILD_DOCS_MANUAL.md)**
3839

@@ -72,6 +73,13 @@ scripts\run_case.bat 0001_two_sum 1
7273

7374
### Build Documentation
7475

76+
The build script will:
77+
1. Generate standard mind maps (Markdown)
78+
2. Generate mind maps (HTML)
79+
3. **Ask if you want to generate AI-powered mind maps** (requires OPENAI_API_KEY)
80+
4. Build MkDocs site
81+
5. Copy mind map files
82+
7583
```bash
7684
# Windows
7785
scripts\build_docs.bat
@@ -80,6 +88,8 @@ scripts\build_docs.bat
8088
./scripts/build_docs.sh
8189
```
8290

91+
> **Note:** AI mind map generation is optional. The script will prompt you during the build process. You can skip it if you don't have an OpenAI API key configured.
92+
8393
### Build and Preview Locally
8494

8595
```bash

scripts/build_docs.bat

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,50 @@ echo ============================================
5454
echo.
5555

5656
REM Step 1: Generate Mind Maps (Markdown)
57-
echo [1/4] Generating mind maps (Markdown)...
57+
echo [1/5] Generating mind maps (Markdown)...
5858
"%VENV_PYTHON%" tools/generate_mindmaps.py
5959
if errorlevel 1 (
6060
echo Error: Failed to generate mind maps
6161
exit /b 1
6262
)
6363

6464
REM Step 2: Generate Mind Maps (HTML)
65-
echo [2/4] Generating mind maps (HTML)...
65+
echo [2/5] Generating mind maps (HTML)...
6666
"%VENV_PYTHON%" tools/generate_mindmaps.py --html
6767
if errorlevel 1 (
6868
echo Error: Failed to generate HTML mind maps
6969
exit /b 1
7070
)
7171

72-
REM Step 3: Build MkDocs site
73-
echo [3/4] Building MkDocs site...
72+
REM Step 3: Ask if user wants to generate AI mind maps
73+
echo.
74+
echo [3/5] Generate AI-powered mind maps?
75+
echo Note: This requires OPENAI_API_KEY environment variable
76+
echo.
77+
set /p GENERATE_AI="Generate AI mind maps? (Y/N): "
78+
if /i "%GENERATE_AI%"=="Y" (
79+
echo Generating AI mind maps...
80+
"%VENV_PYTHON%" tools/generate_mindmaps_ai.py
81+
if errorlevel 1 (
82+
echo Warning: Failed to generate AI mind maps (may need OPENAI_API_KEY)
83+
echo Continuing with build...
84+
) else (
85+
echo AI mind maps generated successfully.
86+
)
87+
) else (
88+
echo Skipping AI mind map generation.
89+
)
90+
91+
REM Step 4: Build MkDocs site
92+
echo [4/5] Building MkDocs site...
7493
"%VENV_PYTHON%" -m mkdocs build
7594
if errorlevel 1 (
7695
echo Error: Failed to build MkDocs site
7796
exit /b 1
7897
)
7998

80-
REM Step 4: Copy mind map HTML files
81-
echo [4/4] Copying mind map HTML files...
99+
REM Step 5: Copy mind map HTML files
100+
echo [5/5] Copying mind map HTML files...
82101
if exist "%PROJECT_ROOT%\docs\pages\mindmaps" (
83102
xcopy /E /I /Y "%PROJECT_ROOT%\docs\pages\mindmaps" "%PROJECT_ROOT%\site\pages\mindmaps" >nul
84103
)

scripts/build_docs.sh

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,50 @@ echo "============================================"
5050
echo ""
5151

5252
# Step 1: Generate Mind Maps (Markdown)
53-
echo "[1/4] Generating mind maps (Markdown)..."
53+
echo "[1/5] Generating mind maps (Markdown)..."
5454
"$VENV_PYTHON" tools/generate_mindmaps.py
5555
if [ $? -ne 0 ]; then
5656
echo "Error: Failed to generate mind maps"
5757
exit 1
5858
fi
5959

6060
# Step 2: Generate Mind Maps (HTML)
61-
echo "[2/4] Generating mind maps (HTML)..."
61+
echo "[2/5] Generating mind maps (HTML)..."
6262
"$VENV_PYTHON" tools/generate_mindmaps.py --html
6363
if [ $? -ne 0 ]; then
6464
echo "Error: Failed to generate HTML mind maps"
6565
exit 1
6666
fi
6767

68-
# Step 3: Build MkDocs site
69-
echo "[3/4] Building MkDocs site..."
68+
# Step 3: Ask if user wants to generate AI mind maps
69+
echo ""
70+
echo "[3/5] Generate AI-powered mind maps?"
71+
echo "Note: This requires OPENAI_API_KEY environment variable"
72+
echo ""
73+
read -p "Generate AI mind maps? (y/N): " GENERATE_AI
74+
if [ "$GENERATE_AI" = "y" ] || [ "$GENERATE_AI" = "Y" ]; then
75+
echo "Generating AI mind maps..."
76+
"$VENV_PYTHON" tools/generate_mindmaps_ai.py
77+
if [ $? -ne 0 ]; then
78+
echo "Warning: Failed to generate AI mind maps (may need OPENAI_API_KEY)"
79+
echo "Continuing with build..."
80+
else
81+
echo "AI mind maps generated successfully."
82+
fi
83+
else
84+
echo "Skipping AI mind map generation."
85+
fi
86+
87+
# Step 4: Build MkDocs site
88+
echo "[4/5] Building MkDocs site..."
7089
"$VENV_PYTHON" -m mkdocs build
7190
if [ $? -ne 0 ]; then
7291
echo "Error: Failed to build MkDocs site"
7392
exit 1
7493
fi
7594

76-
# Step 4: Copy mind map HTML files
77-
echo "[4/4] Copying mind map HTML files..."
95+
# Step 5: Copy mind map HTML files
96+
echo "[5/5] Copying mind map HTML files..."
7897
if [ -d "$PROJECT_ROOT/docs/pages/mindmaps" ]; then
7998
cp -r "$PROJECT_ROOT/docs/pages/mindmaps" "$PROJECT_ROOT/site/pages/" 2>/dev/null || true
8099
fi

0 commit comments

Comments
 (0)