commit:     e01ceaed422f53a782300feaebf252773e78c2e4
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 27 18:10:17 2020 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Feb 28 06:17:47 2020 +0000
URL:        https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=e01ceaed

bin/gen-eclass-html.sh: New option -n to create a placeholder file.

The new strict dependencies will cause the build to fail if
eclass-reference/text.xml is missing, because it is needed as
a dependency for index.html of the previous and next documents.
Add an option that makes it possible to create the file, even if
the eclass documentation is missing.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 bin/gen-eclass-html.sh | 50 +++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 43 insertions(+), 7 deletions(-)

diff --git a/bin/gen-eclass-html.sh b/bin/gen-eclass-html.sh
index 10292eb..ed43090 100755
--- a/bin/gen-eclass-html.sh
+++ b/bin/gen-eclass-html.sh
@@ -100,8 +100,35 @@ guesscompress() {
        esac
 }
 
-# We also need the ebuild man page
-for i in $(/usr/bin/qlist eclass-manpages) /usr/share/man/man5/ebuild.5*; do
+usage() {
+       cat <<- EOF >&2
+       Usage: $0 [OPTION]...
+       Convert eclass man pages to HTML.
+
+         -n    do not build anything, only create a placeholder index
+         -h    display this help and exit
+       EOF
+}
+
+while getopts 'nh' opt; do
+       case ${opt} in
+               n) NOMAN=true ;;
+               h) usage; exit 0 ;;
+               *) usage; exit 1 ;;
+       esac
+done
+shift $((OPTIND-1))
+
+MANPAGES=()
+[[ -n ${NOMAN} ]] || MANPAGES=(
+       $(/usr/bin/qlist eclass-manpages)
+       # We also need the ebuild man page
+       /usr/share/man/man5/ebuild.5*
+)
+
+[[ -d ${OUTPUTDIR} ]] || mkdir -p "${OUTPUTDIR}" || exit 1
+
+for i in "${MANPAGES[@]}"; do
        FILEBASE=${i##*/}
        BASENAME="${FILEBASE%.5*}"
        [[ ${BASENAME} != "${FILEBASE}" ]] || continue
@@ -150,15 +177,24 @@ installed by emerging <c>app-doc/eclass-manpages</c>.
 <section>
 <title>Contents</title>
 <body>
-<ul class="list-group">
 EOF
 
-for i in $(find $OUTPUTDIR/ -maxdepth 1 -mindepth 1 -type d | sort); do
-       echo "<li><uri link=\"$(basename $i)/index.html\">$(basename 
$i)</uri></li>" >> ${OUTPUTDIR}/text.xml
-done
+if [[ -n ${NOMAN} ]]; then
+       cat <<- EOF >> "${OUTPUTDIR}"/text.xml
+       <warning>
+       This is only a placeholder. If you see this text in the output document,
+       then the eclass documentation is missing.
+       </warning>
+       EOF
+else
+       echo '<ul class="list-group">' >> "${OUTPUTDIR}"/text.xml
+       for i in $(find "${OUTPUTDIR}" -maxdepth 1 -mindepth 1 -type d | sort); 
do
+               echo "<li><uri link=\"$(basename $i)/index.html\">$(basename 
$i)</uri></li>" >> "${OUTPUTDIR}"/text.xml
+       done
+       echo '</ul>' >> "${OUTPUTDIR}"/text.xml
+fi
 
 cat << EOF >> ${OUTPUTDIR}/text.xml
-</ul>
 </body>
 </section>
 </chapter>

Reply via email to