mirror of
https://github.com/django/django.git
synced 2025-08-26 03:39:11 +00:00
Fixed #36485 -- Added lint-docs check in Tox and GitHub Actions.
The `check` docs target now runs spelling, black, and lint, so all current documentation quality checks can be run with a single command. Also documented the lint-docs check's availability and usage.
This commit is contained in:
parent
f81e6e3a53
commit
43e4d0a142
16
.github/workflows/docs.yml
vendored
16
.github/workflows/docs.yml
vendored
@ -58,3 +58,19 @@ jobs:
|
|||||||
echo "💥 📢 Code blocks in documentation must be reformatted with blacken-docs 📢 💥"
|
echo "💥 📢 Code blocks in documentation must be reformatted with blacken-docs 📢 💥"
|
||||||
fi;
|
fi;
|
||||||
exit $RESULT
|
exit $RESULT
|
||||||
|
|
||||||
|
lint-docs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: lint-docs
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.13'
|
||||||
|
- run: python -m pip install sphinx-lint
|
||||||
|
- name: Build docs
|
||||||
|
run: |
|
||||||
|
cd docs
|
||||||
|
make lint
|
||||||
|
@ -181,6 +181,6 @@ lint:
|
|||||||
@echo
|
@echo
|
||||||
@echo "Documentation lint complete."
|
@echo "Documentation lint complete."
|
||||||
|
|
||||||
check: spelling black
|
check: spelling black lint
|
||||||
@echo
|
@echo
|
||||||
@echo "Style and spelling checks completed."
|
@echo "Style and spelling checks completed."
|
||||||
|
@ -69,11 +69,11 @@ command from any place in the Django source tree:
|
|||||||
$ tox
|
$ tox
|
||||||
|
|
||||||
By default, ``tox`` runs the test suite with the bundled test settings file for
|
By default, ``tox`` runs the test suite with the bundled test settings file for
|
||||||
SQLite, ``black``, ``blacken-docs``, ``flake8``, ``isort``, and the
|
SQLite, ``black``, ``blacken-docs``, ``flake8``, ``isort``, ``lint-docs`` and
|
||||||
documentation spelling checker. In addition to the system dependencies noted
|
the documentation spelling checker. In addition to the system dependencies
|
||||||
elsewhere in this documentation, the command ``python3`` must be on your path
|
noted elsewhere in this documentation, the command ``python3`` must be on your
|
||||||
and linked to the appropriate version of Python. A list of default environments
|
path and linked to the appropriate version of Python. A list of default
|
||||||
can be seen as follows:
|
environments can be seen as follows:
|
||||||
|
|
||||||
.. console::
|
.. console::
|
||||||
|
|
||||||
@ -84,6 +84,7 @@ can be seen as follows:
|
|||||||
flake8>=3.7.0
|
flake8>=3.7.0
|
||||||
docs
|
docs
|
||||||
isort>=5.1.0
|
isort>=5.1.0
|
||||||
|
lint-docs
|
||||||
|
|
||||||
Testing other Python versions and database backends
|
Testing other Python versions and database backends
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -158,8 +158,9 @@ Documentation quality checks
|
|||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
Several checks help maintain Django's documentation quality, including
|
Several checks help maintain Django's documentation quality, including
|
||||||
:ref:`spelling <documentation-spelling-check>` and
|
:ref:`spelling <documentation-spelling-check>`,
|
||||||
:ref:`code block formatting <documentation-code-block-format-check>`.
|
:ref:`code block formatting <documentation-code-block-format-check>`, and
|
||||||
|
:ref:`documentation style <documentation-lint-check>`.
|
||||||
|
|
||||||
These checks are run automatically in CI and must pass before documentation
|
These checks are run automatically in CI and must pass before documentation
|
||||||
changes can be merged. They can also be run locally with a single command:
|
changes can be merged. They can also be run locally with a single command:
|
||||||
@ -215,6 +216,31 @@ installed, run the following command from the ``docs`` directory:
|
|||||||
The formatter will report any issues by printing them to the terminal and will
|
The formatter will report any issues by printing them to the terminal and will
|
||||||
reformat code blocks where possible.
|
reformat code blocks where possible.
|
||||||
|
|
||||||
|
.. _documentation-lint-check:
|
||||||
|
|
||||||
|
Documentation lint check
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Django's documentation is checked for reStructuredText style and formal issues
|
||||||
|
using :pypi:`sphinx-lint`. This helps catch problems like stray tabs, trailing
|
||||||
|
whitespace, excessive line length, and similar formatting problems.
|
||||||
|
|
||||||
|
Once ``sphinx-lint`` is installed, the check can be run with the following
|
||||||
|
command from the ``docs`` directory:
|
||||||
|
|
||||||
|
.. console::
|
||||||
|
|
||||||
|
$ make lint
|
||||||
|
|
||||||
|
The command prints any violations to the terminal in the form
|
||||||
|
``path:line: message``. If problems are encountered:
|
||||||
|
|
||||||
|
* Read the message and fix the indicated issue (for example, remove trailing
|
||||||
|
whitespace, adjust backticks, or replace tabs with spaces).
|
||||||
|
* For long lines consider wrapping text onto new lines or breaking long inline
|
||||||
|
links into named references. The custom line length check should already skip
|
||||||
|
common false positives such as headings, tables and long links.
|
||||||
|
|
||||||
.. _documentation-link-check:
|
.. _documentation-link-check:
|
||||||
|
|
||||||
Link check
|
Link check
|
||||||
|
@ -205,6 +205,7 @@ if "%1" == "lint" (
|
|||||||
)
|
)
|
||||||
|
|
||||||
if "%1" == "check" (
|
if "%1" == "check" (
|
||||||
|
call :run_lint
|
||||||
call :run_black
|
call :run_black
|
||||||
call :run_spelling
|
call :run_spelling
|
||||||
echo.
|
echo.
|
||||||
|
@ -39,6 +39,7 @@ backport
|
|||||||
backported
|
backported
|
||||||
backports
|
backports
|
||||||
backtick
|
backtick
|
||||||
|
backticks
|
||||||
backtraces
|
backtraces
|
||||||
balancer
|
balancer
|
||||||
basename
|
basename
|
||||||
|
11
tox.ini
11
tox.ini
@ -13,6 +13,7 @@ envlist =
|
|||||||
flake8
|
flake8
|
||||||
docs
|
docs
|
||||||
isort
|
isort
|
||||||
|
lint-docs
|
||||||
|
|
||||||
# Add environment to use the default python3 installation
|
# Add environment to use the default python3 installation
|
||||||
[testenv:py3]
|
[testenv:py3]
|
||||||
@ -87,3 +88,13 @@ allowlist_externals =
|
|||||||
commands =
|
commands =
|
||||||
npm install
|
npm install
|
||||||
npm test
|
npm test
|
||||||
|
|
||||||
|
[testenv:lint-docs]
|
||||||
|
basepython = python3
|
||||||
|
usedevelop = false
|
||||||
|
allowlist_externals =
|
||||||
|
make
|
||||||
|
deps = sphinx-lint
|
||||||
|
changedir = docs
|
||||||
|
commands =
|
||||||
|
make lint
|
||||||
|
Loading…
x
Reference in New Issue
Block a user