Skip to content

Commit 7f9bf35

Browse files
smithdc1nessita
authored andcommitted
Refs #36485 -- Grouped docs checks under a unified make check target.
Added a new 'check' rule to the docs Makefile which runs both the black and spelling checks.
1 parent cba7328 commit 7f9bf35

File tree

3 files changed

+47
-8
lines changed

3 files changed

+47
-8
lines changed

docs/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,7 @@ black:
174174
| xargs blacken-docs --rst-literal-block; echo $$? > "$(BUILDDIR)/black/output.txt"
175175
@echo
176176
@echo "Code blocks reformatted"
177+
178+
check: spelling black
179+
@echo
180+
@echo "Style and spelling checks completed."

docs/internals/contributing/writing-documentation.txt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,29 @@ To edit this page, for example, we would edit the file
152152
:source:`docs/internals/contributing/writing-documentation.txt` and rebuild the
153153
HTML with ``make html``.
154154

155+
.. _documentation-checks:
156+
157+
Documentation quality checks
158+
----------------------------
159+
160+
Several checks help maintain Django's documentation quality, including
161+
:ref:`spelling <documentation-spelling-check>` and
162+
:ref:`code block formatting <documentation-code-block-format-check>`.
163+
164+
These checks are run automatically in CI and must pass before documentation
165+
changes can be merged. They can also be run locally with a single command:
166+
167+
.. console::
168+
169+
$ make check
170+
171+
This command runs all current checks and will include any new checks added in
172+
the future.
173+
155174
.. _documentation-spelling-check:
156175

157176
Spelling check
158-
--------------
177+
~~~~~~~~~~~~~~
159178

160179
Before you commit your docs, it's a good idea to run the spelling checker.
161180
You'll need to install :pypi:`sphinxcontrib-spelling` first. Then from the
@@ -180,7 +199,7 @@ one of the following:
180199
.. _documentation-code-block-format-check:
181200

182201
Code block format check
183-
-----------------------
202+
~~~~~~~~~~~~~~~~~~~~~~~
184203

185204
All Python code blocks should be formatted using the :pypi:`blacken-docs`
186205
auto-formatter. This is automatically run by the :ref:`pre-commit hook

docs/make.bat

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,20 +189,36 @@ results in %BUILDDIR%/doctest/output.txt.
189189
)
190190

191191
if "%1" == "spelling" (
192-
%SPHINXBUILD% -b spelling %ALLSPHINXOPTS% %BUILDDIR%/spelling
193-
if errorlevel 1 exit /b 1
194-
echo.
195-
echo.Check finished. Wrong words can be found in %BUILDDIR%/^
196-
spelling/output.txt.
192+
call :run_spelling
197193
goto end
198194
)
199195

200196
if "%1" == "black" (
197+
call :run_black
198+
goto end
199+
)
200+
201+
if "%1" == "check" (
202+
call :run_black
203+
call :run_spelling
204+
echo.
205+
echo.All checks completed.
206+
goto end
207+
)
208+
209+
:run_spelling
210+
%SPHINXBUILD% -b spelling %ALLSPHINXOPTS% %BUILDDIR%/spelling
211+
if errorlevel 1 exit /b 1
212+
echo.
213+
echo.Check finished. Wrong words can be found in %BUILDDIR%/spelling/output.txt.
214+
exit /b
215+
216+
:run_black
201217
for /f "usebackq tokens=*" %%i in (`dir *.txt /s /b ^| findstr /v /c:"_build" /c:"_theme"`) do (
202218
blacken-docs --rst-literal-block %%i
203219
)
204220
echo.
205221
echo.Code blocks reformatted
206-
)
222+
exit /b
207223

208224
:end

0 commit comments

Comments
 (0)