2022-09-09 14:08:57 +00:00
|
|
|
# shellcheck shell=bash
|
|
|
|
echo "Sourcing sphinx-hook"
|
|
|
|
|
|
|
|
declare -a __sphinxBuilders
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
buildSphinxPhase() {
|
2022-09-09 14:08:57 +00:00
|
|
|
echo "Executing buildSphinxPhase"
|
2022-04-27 09:35:20 +00:00
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
local __sphinxRoot=""
|
2022-04-27 09:35:20 +00:00
|
|
|
runHook preBuildSphinx
|
2022-09-09 14:08:57 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
if [[ -n "${sphinxRoot:-}" ]] ; then # explicit root
|
|
|
|
if ! [[ -f "${sphinxRoot}/conf.py" ]] ; then
|
|
|
|
echo 2>&1 "$sphinxRoot/conf.py: no such file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
__sphinxRoot=$sphinxRoot
|
|
|
|
else
|
2022-09-09 14:08:57 +00:00
|
|
|
for candidate in doc docs doc/source docs/source ; do
|
|
|
|
if [[ -f "$candidate/conf.py" ]] ; then
|
|
|
|
echo "Sphinx documentation found in $candidate"
|
|
|
|
__sphinxRoot=$candidate
|
2022-04-27 09:35:20 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "${__sphinxRoot}" ]] ; then
|
|
|
|
echo 2>&1 "Sphinx documentation not found, use 'sphinxRoot' variable"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
if [ -n "${sphinxBuilders-}" ]; then
|
|
|
|
eval "__sphinxBuilders=($sphinxBuilders)"
|
|
|
|
else
|
|
|
|
__sphinxBuilders=(html)
|
|
|
|
fi
|
|
|
|
|
|
|
|
for __builder in "${__sphinxBuilders[@]}"; do
|
|
|
|
echo "Executing sphinx-build with ${__builder} builder"
|
|
|
|
sphinx-build -M "${__builder}" "${__sphinxRoot}" ".sphinx/${__builder}" -v
|
|
|
|
done
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
runHook postBuildSphinx
|
|
|
|
}
|
|
|
|
|
|
|
|
installSphinxPhase() {
|
2022-09-09 14:08:57 +00:00
|
|
|
echo "Executing installSphinxPhase"
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
local docdir=""
|
|
|
|
runHook preInstallSphinx
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
for __builder in "${__sphinxBuilders[@]}"; do
|
|
|
|
# divert output for man builder
|
|
|
|
if [ "$__builder" == "man" ]; then
|
|
|
|
installManPage .sphinx/man/man/*
|
|
|
|
|
|
|
|
else
|
|
|
|
# shellcheck disable=2154
|
|
|
|
docdir="${doc:-$out}/share/doc/${pname}"
|
2022-04-27 09:35:20 +00:00
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
mkdir -p "$docdir"
|
|
|
|
|
|
|
|
cp -r ".sphinx/${__builder}/${__builder}" "$docdir/"
|
|
|
|
rm -fr "${docdir}/${__builder}/_sources" "${docdir}/${__builder}/.buildinfo"
|
|
|
|
fi
|
|
|
|
done
|
2022-04-27 09:35:20 +00:00
|
|
|
|
|
|
|
runHook postInstallSphinx
|
|
|
|
}
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
preDistPhases+=" buildSphinxPhase installSphinxPhase"
|