# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Carl Smedstad <carsme@archlinux.org>

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

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

check() {
  cd $_pkgname-$pkgver
  python -m installer --destdir=tmp_install dist/*.whl
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  export PYTHONPATH="$PWD/tmp_install/$site_packages"
  pytest
}

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