From: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev] [PATCH 1/1] docs.eclass: add missing python_check_deps() deceleration
Date: Fri, 14 Jul 2023 09:48:22 +0200 [thread overview]
Message-ID: <73de1f68-8f1c-19bb-b0f9-100b89812be7@gentoo.org> (raw)
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
reply other threads:[~2023-07-14 7:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=73de1f68-8f1c-19bb-b0f9-100b89812be7@gentoo.org \
--to=andrewammerlaan@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox