From 60922c8a28e24f819c78d3039be78cbe3de6efe8 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 21 Oct 2024 19:35:42 +0900 Subject: [PATCH] Use pre-commit hook to run doc8 Also create a separate doc requirements to install only required packages during doc build or doc build check. Change-Id: Ic0377868fdc3057314ae1dec0a0db0b1cc0c0b7b --- .pre-commit-config.yaml | 5 +++++ doc/requirements.txt | 4 ++++ test-requirements.txt | 6 ------ tox.ini | 8 +++++++- 4 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 doc/requirements.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 31d9d64..d5b0c7e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,6 +23,11 @@ repos: hooks: - id: hacking additional_dependencies: [] + - repo: https://github.com/PyCQA/doc8 + rev: v1.1.2 + hooks: + - id: doc8 + files: doc/source/.*\.rst$ - repo: https://github.com/asottile/pyupgrade rev: v3.18.0 hooks: diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 0000000..1349f31 --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,4 @@ +sphinx>=2.0.0 # BSD +openstackdocstheme>=2.2.1 # Apache-2.0 +reno>=3.1.0 # Apache-2.0 +fixtures>=3.0.0 # Apache-2.0/BSD diff --git a/test-requirements.txt b/test-requirements.txt index 88f359f..d164f2b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,11 +1,5 @@ coverage>=4.0 # Apache-2.0 python-subunit>=1.0.0 # Apache-2.0/BSD -sphinx>=2.0.0 # BSD -openstackdocstheme>=2.2.1 # Apache-2.0 stestr>=2.0.0 # Apache-2.0 testtools>=2.2.0 # MIT fixtures>=3.0.0 # Apache-2.0/BSD -doc8>=0.8.1 # Apache-2.0 -reno>=3.1.0 # Apache-2.0 - -pre-commit>=2.6.0 # MIT diff --git a/tox.ini b/tox.ini index aeace93..07a87b7 100644 --- a/tox.ini +++ b/tox.ini @@ -18,10 +18,12 @@ commands = commands = oslo_debug_helper {posargs} [testenv:pep8] +deps = + pre-commit>=2.6.0 # MIT + {[testenv:docs]deps} commands = pre-commit run -a sphinx-build -b doctest doc/source doc/build - doc8 --ignore-path "doc/source/history.rst" doc/source [testenv:venv] commands = {posargs} @@ -36,6 +38,9 @@ commands = coverage xml -o cover/coverage.xml [testenv:docs] +deps = + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -r{toxinidir}/doc/requirements.txt commands = sphinx-build -W --keep-going -b html -d doc/build/doctrees doc/source doc/build/html [flake8] @@ -45,5 +50,6 @@ ignore = E123,E125 exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build [testenv:releasenotes] +deps = {[testenv:docs]deps} commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html