Purpose: generate a webpage documenting a script.
Usage: script_page script
Fills in fields in template.html, assumed to be in the working directory.
Changelog:
2023-236 initial development
2023-246 exit on error
Source code (perhaps slightly corrupted) is as follows.
if [ -z "$1" ] || ! [ -f "$1" ]
then
echo "${0}: expected script filename"
exit 1
fi
SCRIPT_NAME="${1%.*}"
SUFFIX="${1##*.}"
PURPOSE=`sed '2 s/^.* - //; 2 p; d' <"$1"`
USAGE=`sed '3 s/^(#|--) usage: //; 3 p; d' <"$1"`
DESC=`sed '/^(#|--)$/,$ d; 1,3 d; s/^(#|--) //' <"$1"`
CHLOG=`sed '1,/^(#|--) Changelog:$/ d; /^(#|--)$/,$ d; s/^(#|--) //; s/^/
/' <"$1"`
SRC=`sed '1,/^$/ d' <"$1"`
PAGE_NAME="${SCRIPT_NAME}.html"
cp template.html "$PAGE_NAME"
BELL=`printf 'x07'`
sub() {
RV=`printf '%s' "$2" | paste -sd "${BELL}"`
RV=`printf '%s
' "$RV" | sed "s/${BELL}/\\\n/g"`
SC="s${BELL}$$1${BELL}$RV${BELL}g"
sed -i "$SC" "$PAGE_NAME"
}
sub script_name "$SCRIPT_NAME"
sub suffix "$SUFFIX"
sub purpose "$PURPOSE"
sub usage "$USAGE"
sub description "$DESC"
sub changelog "$CHLOG"
sub source "$SRC"