Add a nox session for running xdoctest

- add a session "doctests" to nox
- run it as a pre-commit hook
This commit is contained in:
Alexander Hess 2020-10-27 17:56:38 +01:00
parent 4c123d5d01
commit 8dc67c5bdd
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
2 changed files with 20 additions and 0 deletions

View file

@ -3,6 +3,12 @@ fail_fast: true
repos: repos:
- repo: local - repo: local
hooks: 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 - id: fix-branch-references
name: Check for wrong branch references name: Check for wrong branch references
entry: poetry run nox -s fix-branch-references -- entry: poetry run nox -s fix-branch-references --

View file

@ -4,6 +4,8 @@ Nox provides the following tasks:
- "init-project": install the pre-commit hooks - "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 - "fix-branch-references": adjusts links with git branch references in
various files (e.g., Mardown or notebooks) various files (e.g., Mardown or notebooks)
@ -22,6 +24,11 @@ import nox
REPOSITORY = "webartifex/intro-to-python" 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. # Use a unified .cache/ folder for all develop tools.
nox.options.envdir = ".cache/nox" 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") @nox.session(name="fix-branch-references", venv_backend="none")
def fix_branch_references(_session): def fix_branch_references(_session):
"""Change git branch references. """Change git branch references.