summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2016-05-18 03:23:28 -0400
committerMike Frysinger <vapier@gentoo.org>2016-05-18 03:23:28 -0400
commite6bf7714d7911e909bc9f239ef92bb4c5783d668 (patch)
tree2f2f9dc2e70e82f38cf78228b56f9de0348ba361 /docs
parentc9a4a85f3805644e706d0dead02ebb2984458fb3 (diff)
downloadlibgd-e6bf7714d7911e909bc9f239ef92bb4c5783d668.tar.gz
docs: clean up a bit and support `NaturalDocs`
Some installs use `NaturalDocs` instead of `naturaldocs`, so add support for either form.
Diffstat (limited to 'docs')
-rwxr-xr-xdocs/naturaldocs/run_docs.sh51
1 files changed, 47 insertions, 4 deletions
diff --git a/docs/naturaldocs/run_docs.sh b/docs/naturaldocs/run_docs.sh
index dfe1e62..40fec77 100755
--- a/docs/naturaldocs/run_docs.sh
+++ b/docs/naturaldocs/run_docs.sh
@@ -1,18 +1,61 @@
-#!/bin/bash
+#!/bin/sh
set -e
+usage() {
+ echo "Usage: run_docs.sh [--nonfatal]"
+ echo "Generate the manual for gd!"
+ if [ $# -ne 0 ] ; then
+ printf 'ERROR: %b\n' "$*"
+ exit 1
+ else
+ exit 0
+ fi
+}
+
+nd() {
+ # Figure out the name of this tool.
+ if which naturaldocs 2>/dev/null ; then
+ return
+ elif which NaturalDocs 2>/dev/null ; then
+ return
+ else
+ return 1
+ fi
+}
+
+cd "$(dirname "$0")"
+
+if [ $# -eq 1 ] ; then
+ case $1 in
+ --nonfatal)
+ if ! nd >/dev/null ; then
+ echo "skipping doc generation -- please install naturaldoc!"
+ exit 0
+ fi
+ ;;
+ -h|--help)
+ usage
+ ;;
+ *)
+ usage "unknown option: $1"
+ ;;
+ esac
+elif [ $# -ne 0 ] ; then
+ usage "unknown options: $*"
+fi
+
# Version number
VERSION=`(cd ../../; perl config/getver.pl)`
# Clear away old docs and ensure the doc dir. is present.
-[ -d html ] && rm -rf html
+rm -rf html
mkdir html
# Create a lightly-processed copy of the source to use as input. This
# file skips all non-C code in src/ and removes the BGD_DECLARE()
# macro from definitions so they don't show up in the docs.
-[ -d tmp ] && rm -rf tmp
+rm -rf tmp
mkdir tmp
perl nobgd.pl ../../src/ tmp/
@@ -22,7 +65,7 @@ sed -e "s/@VERSION@/$VERSION/g" preamble.txt > tmp/preamble.txt
# ^^^ hack to get the version number in the docs.
# Run naturaldocs to create the manual.
-naturaldocs --rebuild --rebuild-output --documented-only \
+$(nd) --rebuild --rebuild-output --documented-only \
-i tmp/ \
-o html html \
--project project/