diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 40d4f46..676b025 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,6 +3,12 @@ fail_fast: true repos: - repo: local hooks: + - id: doctests + name: Run the xdoctests in the source files + entry: poetry run nox -s doctests -- + language: system + stages: [commit, merge-commit] + types: [python] - id: fix-branch-references name: Check for wrong branch references entry: poetry run nox -s fix-branch-references -- diff --git a/noxfile.py b/noxfile.py index e77cc26..869cdab 100644 --- a/noxfile.py +++ b/noxfile.py @@ -4,6 +4,8 @@ Nox provides the following tasks: - "init-project": install the pre-commit hooks +- "doctests": run the xdoctests in the source files + - "fix-branch-references": adjusts links with git branch references in various files (e.g., Mardown or notebooks) @@ -22,6 +24,11 @@ import nox REPOSITORY = "webartifex/intro-to-python" +SRC_LOCATIONS = ( + "02_functions/sample_module.py", + "11_classes/sample_package", +) + # Use a unified .cache/ folder for all develop tools. nox.options.envdir = ".cache/nox" @@ -45,6 +52,13 @@ def init_project(session): ) +@nox.session(venv_backend="none") +def doctests(session): + """Run the xdoctests in the source files.""" + for location in SRC_LOCATIONS: + session.run("poetry", "run", "xdoctest", "--silent", location) + + @nox.session(name="fix-branch-references", venv_backend="none") def fix_branch_references(_session): """Change git branch references.