diff --git a/eclass/docs.eclass b/eclass/docs.eclass index 8aa2b54d2b2f1..5a63044a86462 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