# Maintainer: Carl Smedstad <carsme@archlinux.org>

pkgname=mkdocs-autorefs
_pkgname=autorefs
pkgver=1.4.4
pkgrel=1
pkgdesc="Automatically link across pages in MkDocs"
arch=(any)
url="https://github.com/mkdocstrings/autorefs"
license=(ISC)
depends=(
  mkdocs
  python
  python-jinja
  python-markdown
  python-markupsafe
)
makedepends=(
  python-build
  python-installer
  python-pdm-backend
  python-wheel
)
checkdepends=(
  mkdocs-material
  python-pygments
  python-pymdown-extensions
  python-pytest
)
source=("$url/archive/$pkgver/$pkgname-$pkgver.tar.gz")
b2sums=('fb0e7c6c3129aa45ed63ca562b4a0c792d5d1dd15fac0499e6a92d55b04b009bf093c7b6ad61ae169d2f13dd71865dabfba6950fa8f4de6ac89c3481287f3cf5')

build() {
  cd $_pkgname-$pkgver
  export PDM_BUILD_SCM_VERSION=$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $_pkgname-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  # tests/test_api.py requires griffe, which is not in repos
  test-env/bin/python -m pytest \
    --ignore tests/test_api.py
}

package() {
  cd $_pkgname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
