# Maintainer : Daniel Bermond <dbermond@archlinux.org>
# Maintainer : Santiago Torres-Arias <santiago@archlinux.org>
# Contributor: Simon Boulay <simon.boulay@alkeona.net>

pkgname=python-breathe
pkgver=5.0.0a5
pkgrel=1
pkgdesc='An extension to reStructuredText and Sphinx to be able to read and render Doxygen xml output'
arch=('any')
url='https://breathe.readthedocs.org/en/latest/'
license=('BSD-3-Clause')
depends=(
    'python'
    'python-docutils'
    'python-pygments'
    'python-sphinx')
makedepends=(
    'python-build'
    'python-flit-core'
    'python-installer'
    'python-setuptools'
    'python-wheel'
    'ruff')
checkdepends=(
    'doxygen'
    'python-pytest')
source=("https://github.com/michaeljones/breathe/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha512sums=('a1ec41b5f7483a500f1bb09cb94e68b259cbd07820518d478618415eade7fb15596cf298b75311577294c12714033a4269592184e826c4f2dc7f37eb24f1b98a')

build() {
  cd "breathe-${pkgver}"
  make parser
  make format-parser
  python -m build --wheel --no-isolation
}

check() {
  cd "breathe-${pkgver}"
  
  # https://github.com/breathe-doc/breathe/issues/1036#issuecomment-3054012476
  PYTHONPATH="$PWD" pytest -k 'not test_example[group] and not test_example[headings]'
}

package_python-breathe() {
  python -m installer --destdir="$pkgdir" "breathe-${pkgver}/dist"/*.whl
  
  local _pyver
  _pyver="$(python -c 'import sys; print("%s.%s" %sys.version_info[:2])')"
  install -d -m755 "${pkgdir}/usr/share/licenses/${pkgname}"
  ln -s "../../../lib/python${_pyver}/site-packages/breathe-${pkgver}.dist-info/licenses/LICENSE" \
    "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
