From 612a1011208b7ed8709dd02fbdb2dbc6bd28a348 Mon Sep 17 00:00:00 2001 From: Kevin O'Donnell Date: Mon, 18 Jan 2021 00:59:06 -0500 Subject: [PATCH] fix: correct annotation declaration and bashadoc Signed-off-by: Kevin O'Donnell --- bash/annotations.sh | 7 +++++-- bash/bashadoc | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bash/annotations.sh b/bash/annotations.sh index 44f97d9..17be80d 100644 --- a/bash/annotations.sh +++ b/bash/annotations.sh @@ -5,11 +5,14 @@ source "$(dirname "${BASH_SOURCE[0]}")/includer.sh" @include doc @include log -@package . +@package annotations -function deprecated() { +function annotations::deprecated() { @doc Mark a function as deprecated local newfunc=$1 log::debug "${FUNCNAME[1]} is deprecated. Replace with $newfunc" "$@" } +function deprecated() { + annotations::deprecated "$@" +} diff --git a/bash/bashadoc b/bash/bashadoc index 93c708c..6febdb6 100755 --- a/bash/bashadoc +++ b/bash/bashadoc @@ -6,20 +6,20 @@ source "$1" package=$(grep "@package" "$1" | awk '{print $NF}' | tail -1) funcs=$(declare -F | awk '{print $NF}' | grep -v "@") if [ "$package" != "." ]; then - title="$package ($(basename "$1"))" + title="\`$package\`" funcs=$(echo "$funcs" | grep "^$package::") else title="$1" funcs=$(echo "$funcs" | grep -v "::") fi -echo "# $title function documentation " +echo "# $title package" for func in $funcs; do - docs=$(declare -f "$func" | grep "^\s*@doc " | sed -e 's/^\s*@doc//') - args=$(declare -f "$func" | grep "^\s*@arg " | sed -e 's/^\s*@arg/ /') + docs=$(declare -f "$func" | grep "^\s*@doc " | sed -e 's/^\s*@doc\ *//') + args=$(declare -f "$func" | grep "^\s*@arg " | sed -e 's/^\s*@arg\ */ - \$/') echo - echo "## $func" + echo "## \`$func\`" echo - [ -n "$docs" ] && echo "$docs" | tr ";" " " + [ -n "$docs" ] && echo "$docs" | tr ";" " " | sed -e 's/\ $//' [ -n "$args" ] && echo && echo "### Arguments" && echo && echo "$args" | tr ";" " " done