# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=python-sphinxcontrib-devhelp
_name=${pkgname#python-}
pkgver=2.0.0
pkgrel=4
pkgdesc='Sphinx extension which outputs Devhelp document'
arch=(any)
url=https://github.com/sphinx-doc/sphinxcontrib-devhelp
license=(BSD-2-Clause)
depends=(python)
makedepends=(
  git
  python-build
  python-flit-core
  python-installer
)
checkdepends=(
  python-pytest
  python-sphinx
)
source=("git+$url.git#tag=$pkgver")
b2sums=('eb855351bc390f6d7e481720bd6fb31ff59dc75bcaa131e8bf14edae820857600b9222b6105cea6a7740c8bc05d0ef4c2f815bf30099ddeda474d069c12ae0b4')

build() {
  cd "$_name"
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "$_name"
  PYTHONPATH="sphinxcontrib/devhelp:$PYTHONPATH" pytest
}

package() {
  cd "$_name"
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/"${_name//-/_}"-$pkgver.dist-info/LICENSE \
    "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
