public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/1] docs.eclass: add missing python_check_deps() deceleration
@ 2023-07-14  7:48 Andrew Ammerlaan
  0 siblings, 0 replies; only message in thread
From: Andrew Ammerlaan @ 2023-07-14  7:48 UTC (permalink / raw
  To: gentoo-dev

This patch moves some things around so we can then easily define a 
python_check_deps() function. The lack of this function causes problems 
when building the documentation of packages that already have py3.12 in 
compat while mkdocs does not have py3.12 yet. [1]

As an added bonus, some code duplication is removed.

Best regards,
Andrew

[1] https://bugs.gentoo.org/910278


 From 4f758c021094db0e4f2a085aba33a614f97200d1 Mon Sep 17 00:00:00 2001
From: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Date: Fri, 14 Jul 2023 09:40:59 +0200
Subject: [PATCH] docs.eclass: define python_check_deps()

and remove some code duplication

Closes: https://bugs.gentoo.org/910278
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
---
  eclass/docs.eclass | 59 ++++++++++++++++++++++++++--------------------
  1 file changed, 33 insertions(+), 26 deletions(-)

diff --git a/eclass/docs.eclass b/eclass/docs.eclass
index da598226bfc0..1aa4937a6363 100644
--- a/eclass/docs.eclass
+++ b/eclass/docs.eclass
@@ -186,21 +186,36 @@ initialize_git_repo() {
  	fi
  }

-# @FUNCTION: python_append_deps
+# @FUNCTION: _docs_set_python_deps
  # @INTERNAL
  # @DESCRIPTION:
-# Appends [\${PYTHON_USEDEP}] to all dependencies
-# for python based DOCS_BUILDERs such as mkdocs or
-# sphinx.
-python_append_deps() {
+# Add python_gen_any_dep or python_gen_cond_dep
+# to DOCS_DEPEND and define python_check_deps
+_docs_set_python_deps() {
  	debug-print-function ${FUNCNAME}

-	local temp
+	local deps=${@}
+	python_check_deps() {
+		use doc || return 0
+
+		local dep
+		for dep in ${deps[@]}; do
+			python_has_version "${dep}[${PYTHON_USEDEP}]" ||
+				return 1
+		done
+	}
+
+	local deps_appended
  	local dep
-	for dep in ${DOCS_DEPEND[@]}; do
-		temp+=" ${dep}[\${PYTHON_USEDEP}]"
+	for dep in ${deps[@]}; do
+		deps_appended+=" ${dep}[\${PYTHON_USEDEP}]"
  	done
-	DOCS_DEPEND=${temp}
+
+	if [[ ${_PYTHON_SINGLE_R1_ECLASS} ]]; then
+		DOCS_DEPEND=$(python_gen_cond_dep "${deps_appended}")
+	else
+		DOCS_DEPEND=$(python_gen_any_dep "${deps_appended}")
+	fi
  }

  # @FUNCTION: sphinx_deps
@@ -212,8 +227,8 @@ sphinx_deps() {

  	: "${DOCS_AUTODOC:=1}"

-	deps="dev-python/sphinx[\${PYTHON_USEDEP}]
-			${DOCS_DEPEND}"
+	deps="dev-python/sphinx
+		${DOCS_DEPEND}"
  	if [[ ${DOCS_AUTODOC} == 0 ]]; then
  		if [[ -n "${DOCS_DEPEND}" ]]; then
  			die "${FUNCNAME}: do not set DOCS_AUTODOC to 0 if external plugins 
are used"
@@ -221,11 +236,8 @@ sphinx_deps() {
  	elif [[ ${DOCS_AUTODOC} != 0 && ${DOCS_AUTODOC} != 1 ]]; then
  		die "${FUNCNAME}: DOCS_AUTODOC should be set to 0 or 1"
  	fi
-	if [[ ${_PYTHON_SINGLE_R1_ECLASS} ]]; then
-		DOCS_DEPEND="$(python_gen_cond_dep "${deps}")"
-	else
-		DOCS_DEPEND="$(python_gen_any_dep "${deps}")"
-	fi
+
+	_docs_set_python_deps ${deps}
  }

  # @FUNCTION: sphinx_compile
@@ -276,19 +288,16 @@ mkdocs_deps() {

  	: "${DOCS_AUTODOC:=0}"

-	deps="dev-python/mkdocs[\${PYTHON_USEDEP}]
-			${DOCS_DEPEND}"
+	deps="dev-python/mkdocs
+		${DOCS_DEPEND}"
  	if [[ ${DOCS_AUTODOC} == 1 ]]; then
-		deps="dev-python/mkautodoc[\${PYTHON_USEDEP}]
+		deps="dev-python/mkautodoc
  				${deps}"
  	elif [[ ${DOCS_AUTODOC} != 0 && ${DOCS_AUTODOC} != 1 ]]; then
  		die "${FUNCNAME}: DOCS_AUTODOC should be set to 0 or 1"
  	fi
-	if [[ ${_PYTHON_SINGLE_R1_ECLASS} ]]; then
-		DOCS_DEPEND="$(python_gen_cond_dep "${deps}")"
-	else
-		DOCS_DEPEND="$(python_gen_any_dep "${deps}")"
-	fi
+
+	_docs_set_python_deps ${deps}
  }

  # @FUNCTION: mkdocs_compile
@@ -404,11 +413,9 @@ IUSE+=" doc"
  # Call the correct setup function
  case ${DOCS_BUILDER} in
  	"sphinx")
-		python_append_deps
  		sphinx_deps
  		;;
  	"mkdocs")
-		python_append_deps
  		mkdocs_deps
  		;;
  	"doxygen")
-- 
2.41.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-14  7:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-14  7:48 [gentoo-dev] [PATCH 1/1] docs.eclass: add missing python_check_deps() deceleration Andrew Ammerlaan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox