Skip to content

Commit

Permalink
fix: correct annotation declaration and bashadoc
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin O'Donnell <kevin@blockchaintp.com>
  • Loading branch information
scealiontach committed Jan 18, 2021
1 parent 698336d commit 612a101
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions bash/annotations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
}
12 changes: 6 additions & 6 deletions bash/bashadoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 612a101

Please sign in to comment.