# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{12..14} )

inherit meson python-any-r1

DESCRIPTION="Command line Kiwix tools: kiwix-serve, kiwix-manage, kiwix-search"
HOMEPAGE="https://github.com/kiwix/kiwix-tools"
SRC_URI="
	https://github.com/kiwix/kiwix-tools/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz
"

LICENSE="GPL-3+"
SLOT="0"
KEYWORDS="~amd64"

# dependency versioning from meson.build
DEPEND="
	www-misc/libkiwix:0/14
	=app-arch/libzim-9*:=
	dev-cpp/docopt
"
RDEPEND="${DEPEND}"
BDEPEND="
	doc? (
		$(python_gen_any_dep '
			dev-python/sphinx[${PYTHON_USEDEP}]
			dev-python/sphinx-rtd-theme[${PYTHON_USEDEP}]
		')
	)
"

IUSE="doc"

pkg_setup() {
	use doc && python-any-r1_pkg_setup
}

src_compile() {
	meson_src_compile
	build_sphinx "${S}/docs"
}