# Maintainer: Evangelos Foutras <foutrelis@archlinux.org>
# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: Timm Preetz <timm@preetz.us>

pkgname=python-pygments
pkgver=2.19.2
pkgrel=1
pkgdesc="Python syntax highlighter"
arch=('any')
url="https://pygments.org/"
license=('BSD-2-Clause')
depends=('python')
makedepends=(
  'python-build'
  'python-hatchling'
  'python-installer'
  'python-setuptools'
  'python-sphinx'
  'python-wcag-contrast-ratio'
  'python-wheel'
)
checkdepends=(
  'python-lxml'
  'python-pytest'
)
provides=('pygmentize')
conflicts=('pygmentize')
replaces=('pygmentize')
source=("https://github.com/pygments/pygments/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha256sums=('542e317dffd5287585b7bc4327969fe2f8d4b7ccec0b46045a83ef45dc840ed9')

build() {
  cd ${pkgname#python-}-$pkgver
  python -m build --wheel --no-isolation
  make -C doc html
}

check() {
  cd ${pkgname#python-}-$pkgver
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl
  test-env/bin/python -m pytest
}

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

  mkdir -vp "$pkgdir/usr/share/doc"
  cp -vrT doc/_build/html "$pkgdir/usr/share/doc/$pkgname"
  install -vDm644 doc/pygmentize.1 -t "$pkgdir/usr/share/man/man1"
  install -vDm644 external/pygments.bashcomp \
    "$pkgdir/usr/share/bash-completion/completions/pygmentize"
}

# vim:set ts=2 sw=2 et:
