Repository navigation
Expand file tree
/
Copy pathpreview-docs.bat
More file actions
66 lines (56 loc) · 1.9 KB
/
Copy pathpreview-docs.bat
File metadata and controls
66 lines (56 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@echo off
setlocal EnableExtensions DisableDelayedExpansion
title Markup UI Documentation Preview
cd /d "%~dp0"
if errorlevel 1 goto failed
rem Always use the interpreter inside this project's virtual environment.
set "DOCS_PYTHON=%~dp0.venv-zensical\Scripts\python.exe"
if exist "%DOCS_PYTHON%" goto environment_ready
echo [1/3] Creating the local Python environment...
py -3 --version >nul 2>&1
if errorlevel 1 goto try_python
py -3 -m venv "%~dp0.venv-zensical"
if errorlevel 1 goto failed
goto environment_ready
:try_python
python --version >nul 2>&1
if errorlevel 1 goto python_missing
python -m venv "%~dp0.venv-zensical"
if errorlevel 1 goto failed
:environment_ready
echo [2/3] Installing documentation dependencies...
rem Prefer the project's own dependency list, shared with CI.
if exist "%~dp0requirements-docs.txt" goto install_docs_requirements
if exist "%~dp0requirements.txt" goto install_requirements
echo No requirements file found. Installing Zensical.
"%DOCS_PYTHON%" -m pip install zensical==0.0.74
if errorlevel 1 goto failed
goto configuration_check
:install_docs_requirements
"%DOCS_PYTHON%" -m pip install -r "%~dp0requirements-docs.txt"
if errorlevel 1 goto failed
goto configuration_check
:install_requirements
"%DOCS_PYTHON%" -m pip install -r "%~dp0requirements.txt"
if errorlevel 1 goto failed
:configuration_check
set "DOCS_CONFIG=%~dp0zensical.toml"
if exist "%DOCS_CONFIG%" goto preview
echo.
echo ERROR: No zensical.toml found beside this BAT file.
echo Add the site configuration and docs source files, then run this BAT again.
goto failed
:preview
echo [3/3] Starting the bilingual live preview...
"%DOCS_PYTHON%" scripts\preview-docs.py
if errorlevel 1 goto failed
exit /b 0
:python_missing
echo.
echo ERROR: Python 3 was not found. Install Python 3 with pip and PATH enabled.
goto failed
:failed
echo.
echo Preview could not start. Review the error above and run this BAT again.
pause
exit /b 1