@@ -7,19 +7,108 @@ SPHINXOPTS ?=
7
7
SPHINXBUILD ?= sphinx-build
8
8
SOURCEDIR = .
9
9
BUILDDIR = _build
10
+ SPELLING_CONFIG = spellingcheck.yaml
10
11
11
12
# Put it first so that "make" without argument is like "make help".
12
13
help :
13
14
@$(SPHINXBUILD ) -M help " $( SOURCEDIR) " " $( BUILDDIR) " $(SPHINXOPTS ) $(O )
15
+ @echo " "
16
+ @echo " Additional spelling targets:"
17
+ @echo " install-spelling-deps Install pyspelling and aspell dependencies"
18
+ @echo " run Build docs and run pyspelling"
19
+ @echo " spelling Run pyspelling on existing build"
14
20
15
- .PHONY : help Makefile
21
+ .PHONY : help Makefile install-spelling-deps spelling run
22
+
23
+ # Check if required dependencies are installed, install if missing
24
+ check-spelling-deps :
25
+ @echo " Checking for required spelling dependencies..."
26
+ @if ! command -v aspell > /dev/null 2>&1 ; then \
27
+ echo " aspell is not installed. Installing dependencies..." ; \
28
+ $(MAKE ) install-spelling-deps; \
29
+ elif ! python3 -c " import pyspelling" 2> /dev/null; then \
30
+ echo " pyspelling is not installed. Installing dependencies..." ; \
31
+ $(MAKE ) install-spelling-deps; \
32
+ else \
33
+ echo " All spelling dependencies are installed." ; \
34
+ fi
35
+
36
+ # Install spelling dependencies
37
+ install-spelling-deps :
38
+ @echo " Installing spelling dependencies..."
39
+ @echo " Detecting operating system..."
40
+ @if command -v apt-get > /dev/null 2>&1 ; then \
41
+ echo " Detected Debian/Ubuntu system" ; \
42
+ echo " Installing aspell and aspell-en..." ; \
43
+ sudo apt-get update && sudo apt-get install -y aspell aspell-en; \
44
+ elif command -v yum > /dev/null 2>&1 ; then \
45
+ echo " Detected RHEL/CentOS system" ; \
46
+ echo " Installing aspell and aspell-en..." ; \
47
+ sudo yum install -y aspell aspell-en; \
48
+ elif command -v dnf > /dev/null 2>&1 ; then \
49
+ echo " Detected Fedora system" ; \
50
+ echo " Installing aspell and aspell-en..." ; \
51
+ sudo dnf install -y aspell aspell-en; \
52
+ elif command -v pacman > /dev/null 2>&1 ; then \
53
+ echo " Detected Arch Linux system" ; \
54
+ echo " Installing aspell and aspell-en..." ; \
55
+ sudo pacman -S --noconfirm aspell aspell-en; \
56
+ elif [ " $$ (uname)" = " Darwin" ]; then \
57
+ echo " Detected macOS system" ; \
58
+ if command -v brew > /dev/null 2>&1 ; then \
59
+ echo " Found Homebrew, installing aspell..." ; \
60
+ brew install aspell; \
61
+ elif command -v port > /dev/null 2>&1 ; then \
62
+ echo " Found MacPorts, installing aspell..." ; \
63
+ sudo port install aspell aspell-dict-en; \
64
+ else \
65
+ echo " Neither Homebrew nor MacPorts found." ; \
66
+ echo " Please install aspell manually:" ; \
67
+ echo " - Install Homebrew: https://brew.sh" ; \
68
+ echo " - Then run: brew install aspell" ; \
69
+ echo " - Or install MacPorts: https://www.macports.org" ; \
70
+ echo " - Then run: sudo port install aspell aspell-dict-en" ; \
71
+ exit 1; \
72
+ fi \
73
+ else \
74
+ echo " Could not detect package manager." ; \
75
+ echo " Please manually install aspell and aspell-en for your system." ; \
76
+ echo " Common package names: aspell, aspell-en" ; \
77
+ exit 1; \
78
+ fi
79
+ @echo " Installing pyspelling via pip..."
80
+ @python3 -m pip install pyspelling
81
+ @echo " Spelling dependencies installed successfully!"
82
+ @echo " You can now run 'make run' to build docs and check spelling."
83
+
84
+ # Check dependencies, install if needed, build HTML documentation, run pyspelling, then serve
85
+ run : check-spelling-deps
86
+ @echo " Building HTML documentation..."
87
+ @$(SPHINXBUILD ) -M html " $( SOURCEDIR) " " $( BUILDDIR) " $(SPHINXOPTS ) $(O )
88
+ @echo " Running spelling check..."
89
+ @if [ ! -f " $( SPELLING_CONFIG) " ]; then \
90
+ echo " Error: Spelling config file '$( SPELLING_CONFIG) ' not found." ; \
91
+ exit 1; \
92
+ fi
93
+ pyspelling -c $(SPELLING_CONFIG )
94
+ @echo " Press Ctrl+C to stop the server"
95
+ sphinx-autobuild -b html " $( SOURCEDIR) " " $( BUILDDIR) " $(SPHINXOPTS ) $(O )
96
+
97
+ # Run pyspelling on existing build
98
+ spelling : check-spelling-deps
99
+ @echo " Running pyspelling with config: $( SPELLING_CONFIG) "
100
+ @if [ ! -f " $( SPELLING_CONFIG) " ]; then \
101
+ echo " Error: Spelling config file '$( SPELLING_CONFIG) ' not found." ; \
102
+ exit 1; \
103
+ fi
104
+ @if [ ! -d " $( BUILDDIR) /html" ]; then \
105
+ echo " Error: HTML build directory '$( BUILDDIR) /html' not found." ; \
106
+ echo " Please run 'make html' first to build the documentation." ; \
107
+ exit 1; \
108
+ fi
109
+ pyspelling -c $(SPELLING_CONFIG ) -j 8
16
110
17
111
# Catch-all target: route all unknown targets to Sphinx using the new
18
112
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
113
% : Makefile
20
114
@$(SPHINXBUILD ) -M $@ " $( SOURCEDIR) " " $( BUILDDIR) " $(SPHINXOPTS ) $(O )
21
-
22
- # Start a local development server to automatically rebuild and serve the HTML documentation
23
- # whenever changes are made to the source files.
24
- run :
25
- sphinx-autobuild " $( SOURCEDIR) " " $( BUILDDIR) " $(SPHINXOPTS ) $(O )
0 commit comments