diff --git a/{{cookiecutter.package_name}}/examples/quickstart.py b/{{cookiecutter.package_name}}/examples/quickstart.py index 52ecf4b..49a87a0 100644 --- a/{{cookiecutter.package_name}}/examples/quickstart.py +++ b/{{cookiecutter.package_name}}/examples/quickstart.py @@ -1,7 +1,6 @@ """Quickstart example -This example script imports the {{cookiecutter.package_name}} package and prints out -the version. +This example script imports our package and prints out the version. """ import logging diff --git a/{{cookiecutter.package_name}}/scripts/cleanup_docs.py b/{{cookiecutter.package_name}}/scripts/cleanup_docs.py index b22ef02..a1c115f 100644 --- a/{{cookiecutter.package_name}}/scripts/cleanup_docs.py +++ b/{{cookiecutter.package_name}}/scripts/cleanup_docs.py @@ -3,16 +3,28 @@ import shutil from pathlib import Path -paths = [ - "docs/build", - "docs/source/api/modules.rst", - "docs/source/api/{{cookiecutter.package_name}}*.rst", +_LITERAL_PATHS = [ + Path("docs/build"), + Path("docs/source/api/modules.rst"), ] +_GLOB_PATTERNS = [ + ("docs/source/api", "reposcan*.rst"), +] + + +def clean() -> None: + """Delete build artefacts and generated API documentation files.""" + for path in _LITERAL_PATHS: + if path.exists(): + if path.is_dir(): + shutil.rmtree(path) + else: + path.unlink() + + for parent_str, pattern in _GLOB_PATTERNS: + for match in Path(parent_str).glob(pattern): + match.unlink() + -for path in paths: - p = Path(path) - if p.exists(): - if p.is_dir(): - shutil.rmtree(p) - else: - p.unlink() +if __name__ == "__main__": + clean() diff --git a/{{cookiecutter.package_name}}/tests/test_examples.py b/{{cookiecutter.package_name}}/tests/test_examples.py index fa28ab8..12d8a3c 100644 --- a/{{cookiecutter.package_name}}/tests/test_examples.py +++ b/{{cookiecutter.package_name}}/tests/test_examples.py @@ -50,9 +50,7 @@ def run_in_venv( else: # Unix-like systems activate_cmd = f". {VENV_DIR}/bin/activate" - args = shlex.split( - f'sh -c "{activate_cmd} && python {filename}"' - ) + args = shlex.split(f'sh -c "{activate_cmd} && python {filename}"') env: dict[str, str] = {} if os.environ.get("PATH"):