Autogenerate empty message docs

This commit is contained in:
ChillerDragon 2023-09-17 11:36:02 +02:00
parent 074812f28b
commit 5a4d4fac6e

View file

@ -46,7 +46,7 @@ function get_msg_of_client_hook() {
local in_func=0 local in_func=0
while IFS='' read -r line while IFS='' read -r line
do do
if [ "$line" == " def $hook(chunk)" ] if [ "$line" == " def $hook(chunk)" ] || [ "$line" == " def $hook" ]
then then
in_func=1 in_func=1
fi fi
@ -59,6 +59,12 @@ function get_msg_of_client_hook() {
if [[ "$line" =~ message\ =\ (.*).new ]] if [[ "$line" =~ message\ =\ (.*).new ]]
then then
echo "${BASH_REMATCH[1]}" echo "${BASH_REMATCH[1]}"
break
fi
if [[ "$line" =~ Context\.new\(nil ]]
then
echo nil
break
fi fi
fi fi
done < lib/game_client.rb done < lib/game_client.rb
@ -98,7 +104,12 @@ function add_hook_doc() {
msg_class="$(get_msg_of_client_hook "$hook")" msg_class="$(get_msg_of_client_hook "$hook")"
if [ "$msg_class" != "" ] if [ "$msg_class" != "" ]
then then
doc_text="context.message is a [$msg_class](../classes/messages/$msg_class.md)" if [ "$msg_class" == "nil" ]
then
doc_text="context.message is nil because there is no message payload."
else
doc_text="context.message is a [$msg_class](../classes/messages/$msg_class.md)"
fi
fi fi
tmpdoc="$tmpdir/doc.md" tmpdoc="$tmpdir/doc.md"
{ {