Skip to content

Commit 6d08806

Browse files
authored
Remove docs tox env if sphinx not selected (#88)
2 parents ff61abf + 5213b93 commit 6d08806

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@
4242
// Mount the parent as /workspaces so we can pip install peers as editable
4343
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
4444
// After the container is created, install the python project in editable form
45-
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]'"
45+
"postCreateCommand": "pip install $([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e '.[dev]' && pre-commit install"
4646
}

template/README.md.jinja

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ how it does it, and why people should use it.
1111
Source | <{{repo_url}}>
1212
:---: | :---:
1313
PyPI | `pip install {{pypi_name}}`
14-
Documentation | <{{docs_url}}>
14+
{% if sphinx %}Documentation | <{{docs_url}}>{% endif %}
1515
Releases | <{{repo_url}}/releases>
1616

1717
This is where you should put some images or code snippets that illustrate
@@ -29,7 +29,8 @@ Or if it is a commandline tool then you might put some example commands here:
2929
```
3030
python -m {{package_name}} --version
3131
```
32-
32+
{% if sphinx %}
3333
<!-- README only content. Anything below this line won't be included in index.md -->
3434

3535
See {{docs_url}} for more detailed documentation.
36+
{% endif %}

template/pyproject.toml.jinja

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ reportMissingImports = false # Ignore missing stubs in imported modules
6161
[tool.pytest.ini_options]
6262
# Run pytest with all our checkers, and don't spam us with massive tracebacks on error
6363
addopts = """
64-
--tb=native -vv --doctest-modules --doctest-glob="*.rst"
64+
--tb=native -vv{% if sphinx %} --doctest-modules --doctest-glob="*.rst"{% endif %}
6565
"""
6666
# https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings
6767
filterwarnings = "error"
@@ -82,22 +82,22 @@ legacy_tox_ini = """
8282
[tox]
8383
skipsdist=True
8484

85-
[testenv:{pre-commit,pyright,pytest,docs}]
85+
[testenv:{pre-commit,pyright,pytest{% if sphinx %},docs{% endif %}}]
8686
# Don't create a virtualenv for the command, requires tox-direct plugin
8787
direct = True
8888
passenv = *
8989
allowlist_externals =
9090
pytest
9191
pre-commit
9292
pyright
93-
sphinx-build
93+
{% if sphinx %} sphinx-build
9494
sphinx-autobuild
95-
commands =
95+
{% endif %}commands =
9696
pytest: pytest --cov={{ package_name }} --cov-report term --cov-report xml:cov.xml {posargs}
9797
pyright: pyright src tests {posargs}
9898
pre-commit: pre-commit run --all-files {posargs}
99-
docs: sphinx-{posargs:build -EW --keep-going} -T docs build/html
100-
"""
99+
{% if sphinx %} docs: sphinx-{posargs:build -EW --keep-going} -T docs build/html
100+
{% endif %}"""
101101

102102
[tool.ruff]
103103
src = ["src", "tests"]

tests/test_example.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,27 @@ def run_pipe(cmd: str, cwd=None):
3636
return output
3737

3838

39-
def test_template(tmp_path: Path):
40-
project_path = tmp_path / "project"
41-
venv_path = tmp_path / "venv"
42-
copy_project(project_path)
39+
def make_venv(project_path: Path) -> callable:
40+
venv_path = project_path / "venv"
41+
run_pipe(f"python -m venv {venv_path}")
4342
run = functools.partial(run_pipe, cwd=str(project_path))
44-
run(f"python -m venv {venv_path}")
45-
run(f"{venv_path}/bin/python -m pip install -e .[dev]")
46-
run(f"{venv_path}/bin/tox -p")
47-
run(f"{venv_path}/bin/python -m pip install build twine")
48-
run(f"{venv_path}/bin/python -m build")
49-
run(f"{venv_path}/bin/python -m twine check --strict dist/*")
43+
run("./venv/bin/pip install -e .[dev]")
44+
return run
45+
46+
47+
def test_template(tmp_path: Path):
48+
copy_project(tmp_path)
49+
run = make_venv(tmp_path)
50+
run("./venv/bin/tox -p")
51+
run("./venv/bin/pip install build twine")
52+
run("./venv/bin/python -m build")
53+
run("./venv/bin/twine check --strict dist/*")
54+
55+
56+
def test_template_no_docs(tmp_path: Path):
57+
copy_project(tmp_path, docs_type="README")
58+
run = make_venv(tmp_path)
59+
run("./venv/bin/tox -p")
5060

5161

5262
def test_bad_repo_name(tmp_path: Path):

0 commit comments

Comments
 (0)