1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/docs/tools/make_table.sh Mon Nov 21 01:19:48 2022 +0100
1.3 @@ -0,0 +1,63 @@
1.4 +#!/bin/sh
1.5 +
1.6 +# Generate a Moin syntax table for header file documentation.
1.7 +
1.8 +DN=$1
1.9 +
1.10 +if [ ! -e "$DN" ] ; then
1.11 + cat 1>&2 <<EOF
1.12 +Usage: $0 <directory>
1.13 +
1.14 +Obtain header file details from within a given include directory.
1.15 +EOF
1.16 + exit 1
1.17 +fi
1.18 +
1.19 +# Obtain the description from the top of a file.
1.20 +
1.21 +get_description()
1.22 +{
1.23 + ENDLINE=$(grep -n -m 1 '^ \*$' "$1" | cut -f 1 -d :)
1.24 + head -n "$ENDLINE" "$1" | tail -n +2 | head -n -1 | sed 's/^ \* //' | concat_lines
1.25 +}
1.26 +
1.27 +# Concatenate lines.
1.28 +
1.29 +concat_lines()
1.30 +{
1.31 + while read LINE ; do
1.32 + echo -n "$LINE "
1.33 + done
1.34 +}
1.35 +
1.36 +# Format a table of header filenames and descriptions.
1.37 +
1.38 +make_table()
1.39 +{
1.40 + for FN in "$1/"*"/"*".h" ; do
1.41 +
1.42 + # Detect non-matching patterns.
1.43 +
1.44 + if [ ! -e "$FN" ] ; then
1.45 + break
1.46 +
1.47 + # Emit the header at the start.
1.48 +
1.49 + elif [ ! "$HEADER" ] ; then
1.50 + echo "|| '''Header File''' §|| '''Contents''' §||"
1.51 + HEADER=1
1.52 + fi
1.53 +
1.54 + PARENT=$(dirname "$FN")
1.55 + SECTION=$(basename "$PARENT")
1.56 + FILENAME=$(basename "$FN")
1.57 +
1.58 + echo -n '|| `'"$SECTION/$FILENAME"'` §|| '
1.59 + get_description "$FN"
1.60 + echo ' §||'
1.61 + done
1.62 +}
1.63 +
1.64 +make_table "$DN" | column -s '§' -t
1.65 +
1.66 +# vim: tabstop=4 expandtab shiftwidth=4