# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>

pkgname=python-commonmark
pkgver=0.9.2
pkgrel=1
pkgdesc='Python parser for the CommonMark Markdown spec'
url='https://pypi.org/project/commonmark/'
arch=('any')
license=('BSD')
depends=('python-docutils')
makedepends=('python-'{build,installer,wheel}
             'python-setuptools'
             'python-sphinx'
             'python-sphinx_rtd_theme')
checkdepends=('python-hypothesis')
options=('!makeflags')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/readthedocs/commonmark.py/archive/${pkgver}.tar.gz)
sha256sums=('65cceb13fad5dd9f53717451afaedde52314254ad180dc2bbb394c600b84ee71')
sha512sums=('d1ecd962b05f410ad6efd1ac6390e3afd4d54592b16d47efd6a66821e5e191f07344f7508516688375acac18cade4d0b542b989c5722d5147d99f6a8983447d1')

build() {
  cd commonmark.py-${pkgver}
  python -m build -wn
  make -C docs man text SPHINXBUILD=sphinx-build
}

check() {
  cd commonmark.py-${pkgver}
  export PYTHONPATH=.
  python commonmark/tests/run_spec_tests.py
}

package() {
  cd commonmark.py-${pkgver}
  python -m installer -d "${pkgdir}" dist/*.whl
  install -Dm 644 README.rst CHANGELOG.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 docs/_build/text/* -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 docs/_build/man/commonmark-py.1 "${pkgdir}/usr/share/man/man1/${pkgname}.1"
  mv "${pkgdir}/usr/bin/cmark"{,-py3}
}

# vim: ts=2 sw=2 et:
