From cd1c6c03b0b7e744fb2f468a64d26102fc3fbc01 Mon Sep 17 00:00:00 2001 From: John Bampton Date: Thu, 23 Oct 2025 23:56:52 +1000 Subject: [PATCH] Auto hot reloading with `sphinx-autobuild` I have tested this on Linux. We need another dev to test the batch file on Windows. I have added this to other projects https://github.com/sphinx-doc/sphinx-autobuild https://github.com/sphinx-doc/sphinx-autobuild?tab=readme-ov-file#using-with-makefile Listed as one of the best Sphinx extensions: https://sphinx-extensions.readthedocs.io/en/latest/ --- Makefile | 7 +++++-- make.bat | 8 ++++++++ requirements.txt | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 011b858e72..a8365ff4f2 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,12 @@ BUILDDIR = build help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -.PHONY: help Makefile +.PHONY: help Makefile livehtml # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +livehtml: + sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/make.bat b/make.bat index d704d3cd64..cb306de298 100644 --- a/make.bat +++ b/make.bat @@ -12,6 +12,9 @@ set BUILDDIR=build set SPHINXPROJ=ApacheCloudStack if "%1" == "" goto help +REM --- Added section for 'livehtml' --- +if "%1" == "livehtml" goto livehtml +REM ------------------------------------- %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( @@ -29,6 +32,11 @@ rd %BUILDDIR% /q /s %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% goto end +:livehtml + REM + sphinx-autobuild "%SOURCEDIR%" "%BUILDDIR%" %SPHINXOPTS% %O% + goto end + :help %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% diff --git a/requirements.txt b/requirements.txt index 1dbf927199..00c9a7fceb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ Sphinx==7.2.6 sphinx-rtd-theme==2.0.0 readthedocs-sphinx-ext==2.2.5 Jinja2==3.1.5 +sphinx-autobuild==2025.8.25