diff mbox series

[v2,01/62] do-not-merge

Message ID 20250309083228.1290253-2-jsnow@redhat.com (mailing list archive)
State New
Headers show
Series docs: Add new QAPI transmogrifier | expand

Commit Message

John Snow March 9, 2025, 8:31 a.m. UTC
Ad-hoc linting scripts to scrub down the new docs/sphinx files. Should
work with a reasonably modern mypy/pylint/etc, and Sphinx 8.2.0. Older
versions of Sphinx ought to still work at runtime, but may not type
check correctly.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi-lint.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100755 scripts/qapi-lint.sh
diff mbox series

Patch

diff --git a/scripts/qapi-lint.sh b/scripts/qapi-lint.sh
new file mode 100755
index 00000000000..738490352cd
--- /dev/null
+++ b/scripts/qapi-lint.sh
@@ -0,0 +1,57 @@ 
+#!/usr/bin/env bash
+set -e
+
+if [[ -f qapi/.flake8 ]]; then
+    echo "flake8 --config=qapi/.flake8 qapi/"
+    flake8 --config=qapi/.flake8 qapi/
+fi
+if [[ -f qapi/pylintrc ]]; then
+    echo "pylint --rcfile=qapi/pylintrc qapi/"
+    pylint --rcfile=qapi/pylintrc qapi/
+fi
+if [[ -f qapi/mypy.ini ]]; then
+    echo "mypy --config-file=qapi/mypy.ini qapi/"
+    mypy --config-file=qapi/mypy.ini qapi/
+fi
+
+if [[ -f qapi/.isort.cfg ]]; then
+    pushd qapi
+    echo "isort -c ."
+    isort -c .
+    popd
+fi
+
+if [[ -f ../docs/sphinx/qapi_domain.py ]]; then
+    files="qapi_domain.py"
+fi
+if [[ -f ../docs/sphinx/compat.py ]]; then
+    files="${files} compat.py"
+fi
+if [[ -f ../docs/sphinx/collapse.py ]]; then
+    files="${files} collapse.py"
+fi
+
+if [[ -f ../docs/sphinx/qapi_domain.py ]]; then
+    pushd ../docs/sphinx
+
+    set -x
+    mypy --strict $files
+    flake8 --max-line-length=80 $files qapidoc.py
+    isort -c $files qapidoc.py
+    black --line-length 80 --check $files qapidoc.py
+    PYTHONPATH=../../scripts/ pylint \
+        --rc-file ../../scripts/qapi/pylintrc \
+        $files qapidoc.py
+    set +x
+
+    popd
+fi
+
+pushd ../build
+#make -j13
+make check-qapi-schema
+rm -rf docs/
+#make docs
+#make sphinxdocs
+time pyvenv/bin/sphinx-build -v -j 8 -b html -d docs/manual.p/ ../docs/ docs/manual/;
+popd