1- set " ISAACLAB_PATH = %~dp0 "
2- rem build the documentation
1+ @ echo off
2+ setlocal enabledelayedexpansion
3+
4+ set " NAOVA_DOC_PATH = %~dp0 "
5+
36echo [INFO] Building documentation...
47call :extract_python_exe
5- pushd %ISAACLAB_PATH% \docs
6- call !python_exe! -m pip install -r requirements.txt > nul
7- call !python_exe! -m sphinx -b html -d _build\doctrees . _build\html
8- echo [INFO] To open documentation on default browser, run:
9- echo xdg-open " %ISAACLAB_PATH% \docs\_build\html\index.html"
10- popd > nul
11- shift
12- goto :end
8+
9+ if " %python_exe% " == " " (
10+ echo [ERROR] Unable to find a valid Python executable.
11+ echo Possible reasons:
12+ echo 1. Python is not installed.
13+ echo 2. Python is not in the system PATH.
14+ exit /b 1
15+ )
16+
17+ echo [INFO] Using Python: %python_exe%
18+
19+ rem Remove old build
20+ if exist " %NAOVA_DOC_PATH% \docs\_build" (
21+ echo [INFO] Removing old build...
22+ rmdir /s /q " %NAOVA_DOC_PATH% \docs\_build"
23+ )
24+
25+ rem Check if dependencies are already installed
26+ pushd " %NAOVA_DOC_PATH% \docs"
27+
28+ echo [INFO] Checking dependencies...
29+ " %python_exe% " -m pip list | findstr /i " sphinx" > nul
30+ if errorlevel 1 (
31+ echo [INFO] Installing dependencies...
32+ " %python_exe% " -m pip install -q -r requirements.txt
33+ if errorlevel 1 (
34+ echo [ERROR] Failed to install dependencies
35+ popd
36+ exit /b 1
37+ )
38+ ) else (
39+ echo [INFO] Dependencies already installed
40+ )
41+
42+ echo [INFO] Building Sphinx documentation...
43+ " %python_exe% " -m sphinx -b html -d _build\doctrees . _build\html
44+ if errorlevel 1 (
45+ echo [ERROR] Failed to build documentation
46+ popd
47+ exit /b 1
48+ )
49+
50+ popd
51+
52+ echo [INFO] Documentation built successfully!
53+ echo [INFO] Opening documentation...
54+ start " " " %NAOVA_DOC_PATH% \docs\_build\html\index.html"
55+
56+ goto :end
57+
58+ :extract_python_exe
59+ setlocal enabledelayedexpansion
60+ set " python_exe = "
61+
62+ rem Check if using Conda
63+ if defined CONDA_PREFIX (
64+ if exist " !CONDA_PREFIX! \python.exe" (
65+ set " python_exe = !CONDA_PREFIX! \python.exe"
66+ )
67+ )
68+
69+ rem Fallback to system Python
70+ if " !python_exe! " == " " (
71+ for /f " delims=" %%i in ('where python 2^ > nul ') do (
72+ set " python_exe = %%i "
73+ goto :found_python
74+ )
75+ for /f " delims=" %%i in ('where python3 2^ > nul ') do (
76+ set " python_exe = %%i "
77+ goto :found_python
78+ )
79+ )
80+
81+ :found_python
82+ endlocal & set " python_exe = %python_exe% "
83+ exit /b 0
84+
85+ :end
86+ exit /b 0
0 commit comments