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

pkgname=python-sphinxcontrib-serializinghtml
_name=${pkgname#python-}
pkgver=2.0.0
pkgrel=3
pkgdesc='Sphinx extension which outputs "serialized" HTML files (json and pickle)'
arch=(any)
url=https://github.com/sphinx-doc/sphinxcontrib-serializinghtml
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=('da9c959497948b308869321ad8e3ff6baae93948f61180c1b5090b8c453cba12d18147b495653f981fd33a1805829427ae44b135f2bde417e4545ff2c0d77d4b')

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

check() {
  cd "$_name"
  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
}
