From e6bf7714d7911e909bc9f239ef92bb4c5783d668 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 18 May 2016 03:23:28 -0400 Subject: docs: clean up a bit and support `NaturalDocs` Some installs use `NaturalDocs` instead of `naturaldocs`, so add support for either form. --- docs/naturaldocs/run_docs.sh | 51 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) (limited to 'docs') 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/ -- cgit v1.2.1