# Maintainer: David Runge <dvzrv@archlinux.org>

_name=sphinx-argparse
pkgname=python-sphinx-argparse
pkgver=0.5.2
pkgrel=5
pkgdesc="Sphinx extension that automatically documents argparse commands and options"
arch=(any)
url="https://github.com/ashb/sphinx-argparse"
license=(MIT)
depends=(
  python
  python-docutils
  python-sphinx
)
makedepends=(
  git
  python-build
  python-flit-core
  python-installer
  python-wheel
)
checkdepends=(
  python-lxml
  python-pytest
)
optdepends=('python-commonmark: markdown support')
source=(
  "git+$url.git#tag=v$pkgver"
  try-catch-mock-import.patch
)
sha512sums=('a8215989ee111bfc36f133a724847d50587c507b2e94a9d2dd1bd01b068266db7853a22b884e414a0c000b06a3a8f0237c1c1b645342bb40d67aabf56c936fba'
            '254b188ce48cde6e24a0bf246618ee3ccf36962651261fb1bdccfd0ca5e26ccab6b98b5cb0ab00d1b177410f45d6dca047152e9aa731c51d256d88c3359efede')
b2sums=('1d4ecf7d3f08c14f946d9bae2d57f571f59e6b71018b04e6c60412601f6ebd1ffa77dc73f445161d72617d1913e29e4635f0b0bb2d087f813052568225b96577'
        'd0c3f041bafbdf26ece27fd0da22894b6ae7b206759eee19ea5081899cc3afb0407b9dcc1cea146a9546c871224a366febc26a2f2cafd03d95df339282de572a')

prepare() {
  cd $_name
  # Added try-catch for autodoc mock-import
  # https://github.com/sphinx-doc/sphinx-argparse/pull/89
  patch --forward --strip=1 --input=../try-catch-mock-import.patch
}

build() {
  cd $_name
  python -m build --wheel --no-isolation
}

# Tests failing with patch
#check() {
#  cd $_name
#  pytest -vv
#}

package() {
  cd $_name
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENCE.rst -t "$pkgdir/usr/share/licenses/$pkgname/"
}
# vim:set ts=2 sw=2 et:
