Debian Codegraph @

tox.ini

raw
1 [tox]
2 min_version = 4
3 # list of environments to run by default with tox run
4 # using Python 3.14 as the default, this needs to be kept in line with
5 # .github/actions/set-dev-env/action.yml (default Python version)
6 env_list =
7 lint,
8 compile-assets,
9 i18n-compile,
10 py314-docs,
11 py314-tests,
12 a11y-tests
13
14 # convenience label for running tests with a given Python version, aimed at
15 # helping contributors run common tasks without needing to call all the steps
16 # For example to run the tests: tox run -m tests
17 labels =
18 tests = compile-assets, i18n-compile, py314-tests
19 a11y = compile-assets, i18n-compile, py314-docs, a11y-tests
20 i18n = i18n-extract, i18n-compile
21 live-server = compile-assets, i18n-compile, docs-live
22
23 # general tox env configuration
24 # these can be run with any py3{10,14} version, for example:
25 # tox run -e py310-lint
26 [testenv]
27 deps =
28 lint: pre-commit
29 compile-assets: sphinx-theme-builder[cli]
30 profile-docs: py-spy
31 extras =
32 {docs-no-checks, docs-linkcheck, profile-docs}: doc
33 skip_install =
34 lint: true # do not need to install to lint
35 profile-docs: true # avoids issues with py-spy and setting the git repo
36 compile-assets: false
37 package = editable
38 commands =
39 lint: pre-commit run -a
40 compile-assets: stb compile # bundle JavaScript and Sass
41 # can substitute the target directory with any other directory by calling:
42 # tox run -e docs-no-checks -- path/to/other/directory
43 docs-no-checks: sphinx-build {posargs:audit}/site {posargs:audit}/_build
44 # example tox run -e py310-profile-docs -- -o profile.svg -n 100
45 profile-docs: python ./tools/profile.py {posargs}
46
47 # tests can be ran with or without coverage (see examples below),
48 # it is recommended to run compile-assets before running tests
49 # i18n-compile MUST be run before running tests
50 # (see examples below),
51 # tox run -e compile-assets,i18n-compile,py310-tests
52 # if you want to skip the assets and translations compilation step you can run
53 # the tests without `compile-assets,i18n-compile`, for example:
54 # tox run -e py310-tests
55 # run tests with a specific Sphinx version
56 # tox run -e compile-assets,i18n-compile,py310-sphinx70-tests
57 # run tests without coverage
58 # tox run -e compile-assets,i18n-compile,py310-tests-no-cov
59 # by default we will retain playwright traces on failure
60 [testenv:py3{10,11,12,13,14}{,-sphinx70,-sphinxdev,}-tests{,-no-cov}]
61 description = "Run tests Python and Sphinx versions. If a Sphinx version is specified, it will use that version vs the default in pyproject.toml"
62 # need to ensure the package is installed in editable mode
63 package = editable
64 extras =
65 test # install dependencies, includes pytest-playwright - defined in pyproject.toml
66 pass_env = GITHUB_ACTIONS # so we can check if this is run on GitHub Actions
67 deps =
68 coverage[toml]
69 py310-sphinx70-tests: sphinx~=7.0.0
70 py314-sphinxdev: sphinx[test] @ git+https://github.com/sphinx-doc/sphinx.git@master
71 depends =
72 compile-assets,
73 i18n-compile
74 allowlist_externals=
75 playwright
76 bash
77 commands =
78 bash -c 'if [[ "{env:GITHUB_ACTIONS:}" == "true" ]]; then playwright install --with-deps; else playwright install; fi'
79 py3{10,11,12,13,14}{,-sphinx70,-sphinxdev,}-tests: coverage run -m pytest -m "not a11y" {posargs:--tracing=retain-on-failure}
80 py3{10,11,12,13,14}{,-sphinx70,-sphinxdev,}-tests-no-cov: pytest -m "not a11y" {posargs:--tracing=retain-on-failure}
81
82 # run accessibility tests with Playwright and axe-core
83 # compiling the assets is needed before running the tests
84 # tox run -e compile,py314-docs,a11y-tests
85 # by default we will retain playwright traces on failure and run the tests on chromium
86 # to run the tests on firefox you can call:
87 # tox run -e compile,py314-docs,a11y-tests-firefox
88 [testenv:a11y-tests{-chromium,-firefox}]
89 description = "run accessibility tests with Playwright and axe-core"
90 base_python = py314 # keep in sync with tests.yml
91 pass_env = GITHUB_ACTIONS # so we can check if this is run on GitHub Actions
92 extras =
93 test # install dependencies, includes pytest-playwright - defined in pyproject.toml
94 depends =
95 compile-assets,
96 i18n-compile
97 py314-docs
98 allowlist_externals=
99 playwright
100 bash
101 commands =
102 bash -c 'if [[ "{env:GITHUB_ACTIONS:}" == "true" ]]; then playwright install --with-deps; else playwright install; fi'
103 bash -c 'test -d docs/_build/html/ && echo "--- Directory exists ---" || exit -1'
104 a11y-tests{,-chromium}: pytest -m "a11y" --maxfail=1 --browser=chromium {posargs:--tracing=retain-on-failure}
105 a11y-tests-firefox: pytest -m "a11y" --maxfail=5 --browser=firefox {posargs:--tracing=retain-on-failure}
106
107 # build PST documentation with the default or a specific Sphinx version
108 # since we are building the documentation we install the packaged dev version of PST
109 # tox run -e py310-docs
110 # tox run -e py310-sphinx70-docs
111 [testenv:py3{10,14}{,-sphinx70}-docs]
112 description = build the documentation and place in docs/_build/html
113 # suppress Py3.11's new "can't debug frozen modules" warning
114 set_env = PYDEVD_DISABLE_FILE_VALIDATION=1
115 # keep this in sync across all docs environments
116 extras = {[testenv:docs-no-checks]extras}
117 deps =
118 py310-sphinx70-docs: sphinx~=7.0.0
119 py310-sphinx70-docs: astroid>=3.0,!=4.0.3
120 depends =
121 compile-assets,
122 i18n-compile
123 commands =
124 sphinx-build -b html docs/ docs/_build/html -nTv -w warnings.txt
125 python tests/utils/check_warnings.py
126
127 # build the docs without checking for warnings
128 # tox run -e docs-no-checks
129 [testenv:docs-no-checks]
130 description = "Build documentation without checking for warnings"
131 extras = doc
132 package = editable
133 set_env = PYDEVD_DISABLE_FILE_VALIDATION=1
134 depends =
135 compile-assets,
136 i18n-compile
137 commands =
138 sphinx-build {posargs:audit}/site {posargs:audit}/_build
139
140 # recommended for local development, this command will build the PST documentation
141 # with the default Sphinx version and the PST installed in editable mode
142 # tox run -e docs-dev
143 [testenv:docs-dev]
144 description = build the documentation and place in docs/_build/html (dev mode)
145 # suppress Py3.11's new "can't debug frozen modules" warning
146 set_env = PYDEVD_DISABLE_FILE_VALIDATION=1
147 # keep this in sync across all docs environments
148 extras = {[testenv:docs-no-checks]extras}
149 package = editable
150 depends =
151 compile-assets,
152 i18n-compile
153 commands =
154 sphinx-build -b html docs/ docs/_build/html -nTv -w warnings.txt {posargs}
155 python tests/utils/check_warnings.py
156
157 # build the docs with live-reload, if you are working on the docs only (no theme changes) the best option is to call
158 # tox run -e docs-live
159 # this will only watch the docs directory and rebuild the docs when changes are detected
160 # if you are working on the theme (HTML, jinja templates, JS, CSS) and the docs, you can call
161 # tox run -e docs-live-theme
162 [testenv:docs-live{,-theme}]
163 description = "Build and serve the documentation with live-reload"
164 extras =
165 dev
166 package = editable
167 deps =
168 sphinx-theme-builder[cli]
169 # suppress Py3.11's new "can't debug frozen modules" warning
170 set_env = PYDEVD_DISABLE_FILE_VALIDATION=1
171 depends =
172 compile-assets,
173 i18n-compile
174 commands =
175 docs-live-theme: stb serve docs --open-browser --re-ignore=locale|api|_build|\.jupyterlite\.doit\.db
176 docs-live: sphinx-autobuild docs/ docs/_build/html --open-browser --re-ignore=locale|api|_build|\.jupyterlite\.doit\.db
177
178 # check external links in the documentation
179 # tox run -e docs-linkcheck
180 [testenv:docs-linkcheck]
181 description = "Check external links in the documentation"
182 extras = doc
183 allowlist_externals = bash
184 basepython = py314
185 package = editable
186 set_env = PYDEVD_DISABLE_FILE_VALIDATION=1
187 depends =
188 compile-assets,
189 i18n-compile
190 commands =
191 sphinx-build -b linkcheck docs/ docs/_build/linkcheck -w warnings.txt --keep-going -q
192 bash -c "echo 'Linkcheck complete; see docs/_build/linkcheck/output.txt for any errors'"
193
194 # extract translatable files into the POT file and update locale PO files
195 # tox run -e i18n-extract
196 # this will update all locales, to update a single locale you can
197 # pass the locale code, for example to update the Spanish locale only:
198 # tox run -e i18n-extract -- --locale=es
199 [testenv:i18n-extract]
200 description = "Extract translatable messages from the source code and update locale files"
201 extras = i18n
202 package = editable
203 allowlist_externals = bash
204 commands =
205 # explicitly pass this as a bash command to set PST_VERSION
206 bash -c "PST_VERSION=$(pip show pydata-sphinx-theme | grep Version | awk -F': ' '{print $2}') && \
207 pybabel extract . -F babel.cfg -o src/pydata_sphinx_theme/locale/sphinx.pot --keywords='_ __ l_ lazy_gettext' \
208 --project=pydata-sphinx-theme --copyright-holder='PyData developers' --version=$PST_VERSION"
209 pybabel update -i src/pydata_sphinx_theme/locale/sphinx.pot -d src/pydata_sphinx_theme/locale -D sphinx {posargs}
210
211 # add a new locale for translations based on the catalog template
212 # the locale needs to be given in the format of the language code
213 # for example: `tox -e i18n-new-locale -- ss`
214 [testenv:i18n-new-locale]
215 description = "Create a new locale based on our catalog template"
216 extras = {[testenv:i18n-extract]extras}
217 package = editable
218 commands =
219 pybabel init -i src/pydata_sphinx_theme/locale/sphinx.pot -d src/pydata_sphinx_theme/locale -l {posargs}
220
221 # compile translation catalogs to binary MO files
222 # tox run -e i18n-compile
223 [testenv:i18n-compile]
224 description = "Compile translation catalogs to binary MO files"
225 extras = {[testenv:i18n-extract]extras}
226 package = editable
227 commands =
228 pybabel compile -d src/pydata_sphinx_theme/locale -D sphinx