version: 2.1

commands:
  run-tox:
    description: "Run tox"
    parameters:
      version:
        type: string
      sphinx-version:
        type: string
        default: "5,6,7,8,latest,dev"
    steps:
      - checkout
      # NOTE: use Tox 3.x until I understand the syntax for generative environments:
      # https://tox.wiki/en/stable/user_guide.html#generative-environment-list
      - run: pip install --user "tox<4"
      - run: tox -e "<<parameters.version>>-sphinx{<<parameters.sphinx-version>>}"

jobs:
  py38:
    docker:
      - image: 'cimg/python:3.8'
    steps:
      - run-tox:
          version: py38
          sphinx-version: "5,6"
  py39:
    docker:
      - image: 'cimg/python:3.9'
    steps:
      - run-tox:
          version: py39
          sphinx-version: "5,6,7"
  py310:
    docker:
      - image: 'cimg/python:3.10'
    steps:
      - run-tox:
          version: py310
  py311:
    docker:
      - image: 'cimg/python:3.11'
    steps:
      - run-tox:
          version: py311
  py312:
    docker:
      - image: 'cimg/python:3.12'
    steps:
      - run-tox:
          version: py312
  docs:
    docker:
      - image: 'cimg/python:3.12'
    steps:
      - checkout
      - run: pip install --user tox
      - run: tox -e docs

workflows:
  version: 2
  tests:
    jobs:
      - docs
      - py312
      - py311
      - py310
      - py39
      - py38
