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:
parent
4c123d5d01
commit
8dc67c5bdd
2 changed files with 20 additions and 0 deletions
|
@ -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 --
|
||||
|
|
14
noxfile.py
14
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.
|
||||
|
|
Loading…
Reference in a new issue