Skip to content

Commit 2c129c1

Browse files
committed
docs(feat): Add docs justfile for Sphinx automation
why: Provide dedicated task runner for documentation builds with proper port configuration. what: - Add docs/justfile for Sphinx build targets - Configure HTTP port to 8023 for development server - Include watch, serve, and autobuild recipes
1 parent 364813b commit 2c129c1

1 file changed

Lines changed: 191 additions & 0 deletions

File tree

docs/justfile

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# justfile for libtmux documentation
2+
# https://just.systems/
3+
4+
set shell := ["bash", "-uc"]
5+
6+
# Configuration
7+
http_port := "8023"
8+
builddir := "_build"
9+
sphinxopts := ""
10+
sphinxbuild := "uv run sphinx-build"
11+
sourcedir := "."
12+
13+
# File patterns for watching
14+
watch_files := "find .. -type f -not -path '*/\\.*' | grep -i '.*[.]\\(rst\\|md\\)$\\|.*[.]py$\\|CHANGES\\|TODO\\|.*conf\\.py' 2> /dev/null"
15+
16+
# Sphinx options
17+
allsphinxopts := "-d " + builddir + "/doctrees " + sphinxopts + " ."
18+
19+
# List all available commands
20+
default:
21+
@just --list
22+
23+
# ============================================================================
24+
# Build targets
25+
# ============================================================================
26+
27+
# Build HTML documentation
28+
html:
29+
{{ sphinxbuild }} -b html {{ allsphinxopts }} {{ builddir }}/html
30+
@echo ""
31+
@echo "Build finished. The HTML pages are in {{ builddir }}/html."
32+
33+
# Clean build directory
34+
clean:
35+
rm -rf {{ builddir }}/*
36+
37+
# Build directory HTML files
38+
dirhtml:
39+
{{ sphinxbuild }} -b dirhtml {{ allsphinxopts }} {{ builddir }}/dirhtml
40+
@echo ""
41+
@echo "Build finished. The HTML pages are in {{ builddir }}/dirhtml."
42+
43+
# Build single HTML file
44+
singlehtml:
45+
{{ sphinxbuild }} -b singlehtml {{ allsphinxopts }} {{ builddir }}/singlehtml
46+
@echo ""
47+
@echo "Build finished. The HTML page is in {{ builddir }}/singlehtml."
48+
49+
# Build EPUB
50+
epub:
51+
{{ sphinxbuild }} -b epub {{ allsphinxopts }} {{ builddir }}/epub
52+
@echo ""
53+
@echo "Build finished. The epub file is in {{ builddir }}/epub."
54+
55+
# Build LaTeX files
56+
latex:
57+
{{ sphinxbuild }} -b latex {{ allsphinxopts }} {{ builddir }}/latex
58+
@echo ""
59+
@echo "Build finished; the LaTeX files are in {{ builddir }}/latex."
60+
61+
# Build PDF via LaTeX
62+
latexpdf:
63+
{{ sphinxbuild }} -b latex {{ allsphinxopts }} {{ builddir }}/latex
64+
@echo "Running LaTeX files through pdflatex..."
65+
make -C {{ builddir }}/latex all-pdf
66+
@echo "pdflatex finished; the PDF files are in {{ builddir }}/latex."
67+
68+
# Build plain text files
69+
text:
70+
{{ sphinxbuild }} -b text {{ allsphinxopts }} {{ builddir }}/text
71+
@echo ""
72+
@echo "Build finished. The text files are in {{ builddir }}/text."
73+
74+
# Build man pages
75+
man:
76+
{{ sphinxbuild }} -b man {{ allsphinxopts }} {{ builddir }}/man
77+
@echo ""
78+
@echo "Build finished. The manual pages are in {{ builddir }}/man."
79+
80+
# Build JSON output
81+
json:
82+
{{ sphinxbuild }} -b json {{ allsphinxopts }} {{ builddir }}/json
83+
@echo ""
84+
@echo "Build finished; now you can process the JSON files."
85+
86+
# Build HTML help files
87+
htmlhelp:
88+
{{ sphinxbuild }} -b htmlhelp {{ allsphinxopts }} {{ builddir }}/htmlhelp
89+
@echo ""
90+
@echo "Build finished; now you can run HTML Help Workshop with the .hhp project file in {{ builddir }}/htmlhelp."
91+
92+
# Build Qt help files
93+
qthelp:
94+
{{ sphinxbuild }} -b qthelp {{ allsphinxopts }} {{ builddir }}/qthelp
95+
@echo ""
96+
@echo "Build finished; now you can run 'qcollectiongenerator' with the .qhcp project file in {{ builddir }}/qthelp."
97+
98+
# Build Devhelp files
99+
devhelp:
100+
{{ sphinxbuild }} -b devhelp {{ allsphinxopts }} {{ builddir }}/devhelp
101+
@echo ""
102+
@echo "Build finished."
103+
104+
# Build Texinfo files
105+
texinfo:
106+
{{ sphinxbuild }} -b texinfo {{ allsphinxopts }} {{ builddir }}/texinfo
107+
@echo ""
108+
@echo "Build finished. The Texinfo files are in {{ builddir }}/texinfo."
109+
110+
# Build Info files from Texinfo
111+
info:
112+
{{ sphinxbuild }} -b texinfo {{ allsphinxopts }} {{ builddir }}/texinfo
113+
@echo "Running Texinfo files through makeinfo..."
114+
make -C {{ builddir }}/texinfo info
115+
@echo "makeinfo finished; the Info files are in {{ builddir }}/texinfo."
116+
117+
# Build gettext catalogs
118+
gettext:
119+
{{ sphinxbuild }} -b gettext {{ sphinxopts }} . {{ builddir }}/locale
120+
@echo ""
121+
@echo "Build finished. The message catalogs are in {{ builddir }}/locale."
122+
123+
# ============================================================================
124+
# Validation
125+
# ============================================================================
126+
127+
# Check all external links
128+
linkcheck:
129+
{{ sphinxbuild }} -b linkcheck {{ allsphinxopts }} {{ builddir }}/linkcheck
130+
@echo ""
131+
@echo "Link check complete; look for any errors in the above output or in {{ builddir }}/linkcheck/output.txt."
132+
133+
# Run doctests embedded in documentation
134+
doctest:
135+
{{ sphinxbuild }} -b doctest {{ allsphinxopts }} {{ builddir }}/doctest
136+
@echo "Testing of doctests in the sources finished, look at the results in {{ builddir }}/doctest/output.txt."
137+
138+
# Check build from scratch
139+
checkbuild:
140+
rm -rf {{ builddir }}
141+
{{ sphinxbuild }} -n -q ./ {{ builddir }}
142+
143+
# Build redirects configuration
144+
redirects:
145+
{{ sphinxbuild }} -b rediraffewritediff {{ allsphinxopts }} {{ builddir }}/redirects
146+
@echo ""
147+
@echo "Build finished. The redirects are in rediraffe_redirects."
148+
149+
# Show changes overview
150+
changes:
151+
{{ sphinxbuild }} -b changes {{ allsphinxopts }} {{ builddir }}/changes
152+
@echo ""
153+
@echo "The overview file is in {{ builddir }}/changes."
154+
155+
# ============================================================================
156+
# Development
157+
# ============================================================================
158+
159+
# Watch files and rebuild on change
160+
watch:
161+
#!/usr/bin/env bash
162+
set -euo pipefail
163+
if command -v entr > /dev/null; then
164+
${{ watch_files }} | entr -c just html
165+
else
166+
just html
167+
fi
168+
169+
# Serve documentation via Python http.server
170+
serve:
171+
@echo '=============================================================='
172+
@echo ''
173+
@echo 'docs server running at http://localhost:{{ http_port }}/'
174+
@echo ''
175+
@echo '=============================================================='
176+
python -m http.server {{ http_port }} --directory {{ builddir }}/html
177+
178+
# Watch and serve simultaneously
179+
dev:
180+
#!/usr/bin/env bash
181+
set -euo pipefail
182+
just watch &
183+
just serve
184+
185+
# Start sphinx-autobuild server
186+
start:
187+
uv run sphinx-autobuild "{{ sourcedir }}" "{{ builddir }}" {{ sphinxopts }} --port {{ http_port }}
188+
189+
# Design mode: watch static files and disable incremental builds
190+
design:
191+
uv run sphinx-autobuild "{{ sourcedir }}" "{{ builddir }}" {{ sphinxopts }} --port {{ http_port }} --watch "." -a

0 commit comments

Comments
 (0)