2021-03-23 22:23:49 +01:00
|
|
|
#!/bin/bash
|
2021-05-12 00:22:51 +02:00
|
|
|
# Extracts documentation from an org-mode file.
|
2021-03-10 12:58:38 +01:00
|
|
|
|
2021-10-28 17:52:03 +02:00
|
|
|
# Check required environment variables
|
|
|
|
# ------------------------------------
|
2021-03-10 12:58:38 +01:00
|
|
|
|
2021-10-28 17:52:03 +02:00
|
|
|
if [[ -z ${srcdir} ]] ; then
|
|
|
|
echo "Error: srcdir environment variable is not defined"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-03-23 22:23:49 +01:00
|
|
|
|
2022-02-17 23:30:16 +01:00
|
|
|
readonly DOCS=share/doc/qmckl/
|
2021-05-11 11:45:49 +02:00
|
|
|
readonly ORG=${srcdir}/org/
|
|
|
|
readonly HTMLIZE=${DOCS}/html/htmlize.el
|
|
|
|
readonly CONFIG_DOC=${srcdir}/tools/config_doc.el
|
|
|
|
readonly CONFIG_TANGLE=${srcdir}/tools/config_tangle.el
|
2021-03-23 22:23:49 +01:00
|
|
|
|
2021-03-10 12:58:38 +01:00
|
|
|
function extract_doc()
|
|
|
|
{
|
2021-05-12 00:22:51 +02:00
|
|
|
org=$1
|
|
|
|
local_html=${org%.org}.html
|
|
|
|
local_text=${org%.org}.txt
|
|
|
|
html=${DOCS}/html/$(basename ${org%.org}.html)
|
|
|
|
text=${DOCS}/text/$(basename ${org%.org}.txt)
|
|
|
|
|
2021-10-28 17:52:03 +02:00
|
|
|
${srcdir}/tools/missing emacs --batch \
|
|
|
|
--load="${HTMLIZE}" \
|
|
|
|
--load="${CONFIG_DOC}" \
|
|
|
|
${org} \
|
2021-11-17 17:06:30 +01:00
|
|
|
--load="${CONFIG_TANGLE}" \
|
2021-10-28 17:52:03 +02:00
|
|
|
-f org-html-export-to-html \
|
2021-05-12 00:22:51 +02:00
|
|
|
-f org-ascii-export-to-ascii
|
|
|
|
|
2021-10-28 17:52:03 +02:00
|
|
|
rc=$?
|
|
|
|
if [ $rc -ne 0 ] ; then
|
|
|
|
return $rc
|
|
|
|
fi
|
2021-05-12 00:22:51 +02:00
|
|
|
mv ${local_html} ${html}
|
|
|
|
mv ${local_text} ${text}
|
2021-03-10 12:58:38 +01:00
|
|
|
}
|
|
|
|
|
2021-05-12 00:22:51 +02:00
|
|
|
for i in $@
|
|
|
|
do
|
|
|
|
exported=${i%.org}.exported
|
2022-02-17 23:30:16 +01:00
|
|
|
exported=${srcdir}/src/$(basename $exported)
|
2021-05-12 00:22:51 +02:00
|
|
|
NOW=$(date +"%m%d%H%M.%S")
|
2021-10-28 17:52:03 +02:00
|
|
|
extract_doc ${i} &> $exported
|
2021-10-14 21:39:08 +02:00
|
|
|
rc=$?
|
2021-03-10 12:58:38 +01:00
|
|
|
|
2021-05-12 00:22:51 +02:00
|
|
|
# Make log file older than the exported files
|
|
|
|
touch -t ${NOW} $exported
|
2021-10-14 21:39:08 +02:00
|
|
|
|
|
|
|
# Fail if tangling failed
|
2021-10-28 17:52:03 +02:00
|
|
|
if [ $rc -ne 0 ] ; then
|
2021-10-14 21:39:08 +02:00
|
|
|
cat $exported
|
2021-10-28 17:52:03 +02:00
|
|
|
exit $rc
|
2021-10-14 21:39:08 +02:00
|
|
|
fi
|
2021-05-12 00:22:51 +02:00
|
|
|
done
|
2021-03-10 12:58:38 +01:00
|
|
|
|
2021-03-23 22:23:49 +01:00
|
|
|
|