summaryrefslogtreecommitdiff
path: root/eclass/docs.eclass
diff options
context:
space:
mode:
authorAndrew Ammerlaan <andrewammerlaan@gentoo.org>2022-11-16 15:11:09 +0100
committerAndrew Ammerlaan <andrewammerlaan@gentoo.org>2022-11-16 15:11:09 +0100
commit9ddb6565d9c857f2c3a46a558713251c36cd6875 (patch)
treeb1eb148f5cac9598535d528cc1ca85aab8ae62f3 /eclass/docs.eclass
parente22fee1e68347f05d921a8f14d0a264358d62d9b (diff)
downloadgentoo-9ddb6565d9c857f2c3a46a558713251c36cd6875.tar.gz
gentoo-9ddb6565d9c857f2c3a46a558713251c36cd6875.tar.bz2
gentoo-9ddb6565d9c857f2c3a46a558713251c36cd6875.zip
docs.eclass: add initialize_git_repo helper function
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
Diffstat (limited to 'eclass/docs.eclass')
-rw-r--r--eclass/docs.eclass35
1 files changed, 35 insertions, 0 deletions
diff --git a/eclass/docs.eclass b/eclass/docs.eclass
index 8aa2b54d2b2f..5a63044a8646 100644
--- a/eclass/docs.eclass
+++ b/eclass/docs.eclass
@@ -143,6 +143,15 @@ esac
#
# Defaults to Doxyfile for doxygen
+# @ECLASS_VARIABLE: DOCS_INITIALIZE_GIT
+# @DEFAULT_UNSET
+# @PRE_INHERIT
+# @DESCRIPTION:
+# Sometimes building the documentation will fail if this is not done
+# inside a git repository. If this variable is set the compile functions
+# will initialize a dummy git repository before compiling. A dependency
+# on dev-vcs/git is automatically added.
+
if [[ ! ${_DOCS} ]]; then
# For the python based DOCS_BUILDERS we need to inherit any python eclass
@@ -164,6 +173,24 @@ case ${DOCS_BUILDER} in
;;
esac
+# @FUNCTION: initialize_git_repo
+# @DESCRIPTION:
+# Initializes a dummy git repository. This function is called by the
+# documentation compile functions if DOCS_INITIALIZE_GIT is set. It can
+# also be called manually.
+initialize_git_repo() {
+ # Only initialize if we are not already in a git repository
+ local git_is_initialized="$(git rev-parse --is-inside-work-tree 2> /dev/null)"
+ if [[ ! "${git_is_initialized}" ]]; then
+ git init -q || die
+ git config --global user.email "larry@gentoo.org" || die
+ git config --global user.name "Larry the Cow" || die
+ git add . || die
+ git commit -qm "init" || die
+ git tag -a "${PV}" -m "${PN} version ${PV}" || die
+ fi
+}
+
# @FUNCTION: python_append_deps
# @INTERNAL
# @DESCRIPTION:
@@ -216,6 +243,8 @@ sphinx_compile() {
: ${DOCS_DIR:="${S}"}
: ${DOCS_OUTDIR:="${S}/_build/html/sphinx"}
+ [[ ${DOCS_INITIALIZE_GIT} ]] && initialize_git_repo
+
local confpy=${DOCS_DIR}/conf.py
[[ -f ${confpy} ]] ||
die "${FUNCNAME}: ${confpy} not found, DOCS_DIR=${DOCS_DIR} call wrong"
@@ -277,6 +306,8 @@ mkdocs_compile() {
: ${DOCS_DIR:="${S}"}
: ${DOCS_OUTDIR:="${S}/_build/html/mkdocs"}
+ [[ ${DOCS_INITIALIZE_GIT} ]] && initialize_git_repo
+
local mkdocsyml=${DOCS_DIR}/mkdocs.yml
[[ -f ${mkdocsyml} ]] ||
die "${FUNCNAME}: ${mkdocsyml} not found, DOCS_DIR=${DOCS_DIR} wrong"
@@ -320,6 +351,8 @@ doxygen_compile() {
: ${DOCS_DIR:="${S}"}
: ${DOCS_OUTDIR:="${S}/_build/html/doxygen"}
+ [[ ${DOCS_INITIALIZE_GIT} ]] && initialize_git_repo
+
local doxyfile=${DOCS_DIR}/${DOCS_CONFIG_NAME}
[[ -f ${doxyfile} ]] ||
die "${FUNCNAME}: ${doxyfile} not found, DOCS_DIR=${DOCS_DIR} or DOCS_CONFIG_NAME=${DOCS_CONFIG_NAME} wrong"
@@ -388,6 +421,8 @@ case ${DOCS_BUILDER} in
;;
esac
+[[ ${DOCS_INITIALIZE_GIT} ]] && DOCS_DEPEND+=" dev-vcs/git "
+
if [[ ${EAPI} != 6 ]]; then
BDEPEND+=" doc? ( ${DOCS_DEPEND} )"
else