diff --git a/doc-build-test.bat b/doc-build-test.bat index fe998ae..b839525 100644 --- a/doc-build-test.bat +++ b/doc-build-test.bat @@ -1,39 +1,41 @@ -@echo off -setlocal +REM USE doc-test instead!! +echo use doc test... +rem @echo off +rem setlocal -:: Define paths -set REPO_URL=https://github.com/mynl/greater_tables_project -set BUILD_DIR=C:\tmp\greater_tables_docs -set VENV_DIR=%BUILD_DIR%\venv +rem :: Define paths +rem set REPO_URL=https://github.com/mynl/greater_tables_project +rem set BUILD_DIR=C:\tmp\greater_tables_docs +rem set VENV_DIR=%BUILD_DIR%\venv -:: Remove existing directory if it exists -if exist "%BUILD_DIR%" rd /s /q "%BUILD_DIR%" +rem :: Remove existing directory if it exists +rem if exist "%BUILD_DIR%" rd /s /q "%BUILD_DIR%" -:: Clone the latest development repo -git clone --depth 1 %REPO_URL% "%BUILD_DIR%" -if %errorlevel% neq 0 exit /b %errorlevel% +rem :: Clone the latest development repo +rem git clone --depth 1 %REPO_URL% "%BUILD_DIR%" +rem if %errorlevel% neq 0 exit /b %errorlevel% -pushd "%BUILD_DIR%" +rem pushd "%BUILD_DIR%" -:: Create virtual environment -python -m venv "%VENV_DIR%" -if %errorlevel% neq 0 exit /b %errorlevel% +rem :: Create virtual environment +rem python -m venv "%VENV_DIR%" +rem if %errorlevel% neq 0 exit /b %errorlevel% -:: Activate virtual environment -call "%VENV_DIR%\Scripts\activate" +rem :: Activate virtual environment +rem call "%VENV_DIR%\Scripts\activate" -:: Upgrade pip and install dependencies from pyproject.toml -python -m pip install --upgrade pip -pip install --upgrade build setuptools -pip install . -pip install ".[doc]" || pip install sphinx # Ensure Sphinx is installed +rem :: Upgrade pip and install dependencies from pyproject.toml +rem python -m pip install --upgrade pip +rem pip install --upgrade build setuptools +rem pip install . +rem pip install ".[doc]" || pip install sphinx # Ensure Sphinx is installed -:: Build the documentation -sphinx-build -b html docs docs/_build/html -if %errorlevel% neq 0 exit /b %errorlevel% +rem :: Build the documentation +rem sphinx-build -b html docs docs/_build/html +rem if %errorlevel% neq 0 exit /b %errorlevel% -:: Deactivate virtual environment -deactivate +rem :: Deactivate virtual environment +rem deactivate -echo Documentation build complete: %BUILD_DIR%\docs\_build\html -endlocal +rem echo Documentation build complete: %BUILD_DIR%\docs\_build\html +rem endlocal diff --git a/doc-test.bat b/doc-test.bat new file mode 100644 index 0000000..bb202e8 --- /dev/null +++ b/doc-test.bat @@ -0,0 +1,120 @@ +@echo off +setlocal + +:: --- Configuration --- +set "PYTHON_VERSION=3.10" +set "PROJECT_NAME="greater_tables_project" +REM set "PROJECT_REPO=https://github.com/mynl/%PROJECT_NAME%.git" +set "PROJECT_REPO=c:\s\telos\python\greater_tables_project" +set "BUILD_DIR=C:\tmp\%PROJECT_NAME%_rtd_build" +set "VENV_DIR=%BUILD_DIR%\venv" +set "HTML_OUTPUT_DIR=%BUILD_DIR%\html" +set "PORT=9800" + +:: --- Prepare Environment --- +echo Cleaning previous build directory... +pushd C:\tmp +rmdir /s /q "%BUILD_DIR%" >nul 2>&1 +mkdir "%BUILD_DIR%" + +:: --- Clone Repository --- +echo Cloning repository... +git clone --depth 1 "%PROJECT_REPO%" "%BUILD_DIR%" +if %ERRORLEVEL% NEQ 0 ( + echo Git clone failed. Exiting. + exit /b %ERRORLEVEL% +) + +cd "%BUILD_DIR%" + +:: --- Fetch latest changes --- +echo Fetching latest changes... +git fetch origin --force --prune --prune-tags --depth 50 refs/heads/master:refs/remotes/origin/master +if %ERRORLEVEL% NEQ 0 ( + echo Git fetch failed. Exiting. + exit /b %ERRORLEVEL% +) + +:: --- Checkout master branch --- +echo Checking out master branch... +git checkout --force origin/master +if %ERRORLEVEL% NEQ 0 ( + echo Git checkout failed. Exiting. + exit /b %ERRORLEVEL% +) + +:: --- Setup Virtual Environment --- +echo Creating virtual environment for Python %PYTHON_VERSION%... +:: Assuming 'uv' is installed and available in PATH. +:: If not, you might need to install it: uv pip install uv +uv venv "%VENV_DIR%" --python %PYTHON_VERSION% +if %ERRORLEVEL% NEQ 0 ( + echo Failed to create virtual environment. Ensure uv and Python %PYTHON_VERSION% are available. Exiting. + exit /b %ERRORLEVEL% +) + +call "%VENV_DIR%\Scripts\activate.bat" +if %ERRORLEVEL% NEQ 0 ( + echo Failed to activate virtual environment. Exiting. + exit /b %ERRORLEVEL% +) + +:: --- Install Dependencies --- +echo Upgrading setuptools... +uv pip install --upgrade setuptools +if %ERRORLEVEL% NEQ 0 ( + echo Failed to upgrade setuptools. Exiting. + exit /b %ERRORLEVEL% +) + +echo Installing Sphinx... +uv pip install --upgrade sphinx +if %ERRORLEVEL% NEQ 0 ( + echo Failed to install Sphinx. Exiting. + exit /b %ERRORLEVEL% +) + +echo Installing project dependencies from pyproject.toml... +uv pip install --upgrade --no-cache-dir .[dev] +if %ERRORLEVEL% NEQ 0 ( + echo Failed to install project dependencies. Exiting. + exit /b %ERRORLEVEL% +) + +:: --- Build HTML Documentation --- +echo Building HTML documentation... +python -m sphinx -T -b html -d _build\doctrees -D language=en docs "%HTML_OUTPUT_DIR%" +if %ERRORLEVEL% NEQ 0 ( + echo HTML build failed. Exiting. + exit /b %ERRORLEVEL% +) + +echo. +echo HTML documentation built successfully in "%HTML_OUTPUT_DIR%" + +:: --- Launch Web Server and Open Docs --- +echo Launching a simple web server for the documentation... +start /b cmd /c "cd /d "%HTML_OUTPUT_DIR%" && python -m http.server %PORT%" +echo Opening documentation in your default browser... +start "" "http://localhost:%PORT%" + +:: --- Optional: Build LaTeX/PDF (commented out) --- +:: echo Building LaTeX/PDF documentation... +:: python -m sphinx -T -b latex -d _build\doctrees -D language=en docs "%BUILD_DIR%\pdf" +:: if %ERRORLEVEL% NEQ 0 ( +:: echo LaTeX build failed. Exiting. +:: exit /b %ERRORLEVEL% +:: ) +:: +:: echo Running latexmk to generate PDF... +:: cd "%BUILD_DIR%\pdf" +:: latexmk -r latexmkrc -pdf -f -dvi- -ps- -jobname=archivum-project -interaction=nonstopmode +:: if %ERRORLEVEL% NEQ 0 ( +:: echo PDF generation failed. Exiting. +:: exit /b %ERRORLEVEL% +:: ) +:: cd "%BUILD_DIR%" +:: +:: echo PDF documentation built successfully in "%BUILD_DIR%\pdf" + +endlocal diff --git a/greater_tables/greater_tables.py b/greater_tables/greater_tables.py index 17d5398..b6a8cc2 100644 --- a/greater_tables/greater_tables.py +++ b/greater_tables/greater_tables.py @@ -364,8 +364,7 @@ class GT(object): # TODO: implement table_width_mode = table_width_mode.lower() if table_width_mode not in ('explicit', 'natural', 'breakable', 'minimum'): - raise ValueError(f'Inadmissible options { - table_width_mode} for table_width_mode.') + raise ValueError(f'Inadmissible options {table_width_mode} for table_width_mode.') self.table_width_mode = table_width_mode self.table_width_header_adjust = table_width_header_adjust self.table_width_header_relax = table_width_header_relax