Auto generate message class docs
This commit is contained in:
parent
93b4b136af
commit
0dad3f9ca9
6
docs/v0.0.1/classes/messages/ClEmoticon.md
Normal file
6
docs/v0.0.1/classes/messages/ClEmoticon.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# ClEmoticon
|
||||
|
||||
Client -> Server
|
||||
|
||||
### @emoticon [Integer]
|
||||
|
8
docs/v0.0.1/classes/messages/ClSay.md
Normal file
8
docs/v0.0.1/classes/messages/ClSay.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# ClSay
|
||||
|
||||
Client -> Server
|
||||
|
||||
### @mode [Integer]
|
||||
### @target_id [Integer]
|
||||
### @message [String]
|
||||
|
30
docs/v0.0.1/classes/messages/ClientInfo.md
Normal file
30
docs/v0.0.1/classes/messages/ClientInfo.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
# ClientInfo
|
||||
|
||||
Server -> Client
|
||||
|
||||
### @client_id [Integer]
|
||||
### @local [Integer]
|
||||
### @team [Integer]
|
||||
### @name [String]
|
||||
### @clan [String]
|
||||
### @country [Integer]
|
||||
### @body [String]
|
||||
### @marking [String]
|
||||
### @decoration [String]
|
||||
### @hands [String]
|
||||
### @feet [String]
|
||||
### @eyes [String]
|
||||
### @custom_color_body [Integer]
|
||||
### @custom_color_marking [Integer]
|
||||
### @custom_color_decoration [Integer]
|
||||
### @custom_color_hands [Integer]
|
||||
### @custom_color_feet [Integer]
|
||||
### @custom_color_eyes [Integer]
|
||||
### @color_body [Integer]
|
||||
### @color_marking [Integer]
|
||||
### @color_decoration [Integer]
|
||||
### @color_hands [Integer]
|
||||
### @color_feet [Integer]
|
||||
### @color_eyes [Integer]
|
||||
### @silent [Integer]
|
||||
|
5
docs/v0.0.1/classes/messages/GameInfo.md
Normal file
5
docs/v0.0.1/classes/messages/GameInfo.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# GameInfo
|
||||
|
||||
|
||||
|
||||
|
7
docs/v0.0.1/classes/messages/InputTiming.md
Normal file
7
docs/v0.0.1/classes/messages/InputTiming.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# InputTiming
|
||||
|
||||
Server -> Client
|
||||
|
||||
### @intended_tick [Integer]
|
||||
### @time_left [Integer]
|
||||
|
8
docs/v0.0.1/classes/messages/RconCmdAdd.md
Normal file
8
docs/v0.0.1/classes/messages/RconCmdAdd.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# RconCmdAdd
|
||||
|
||||
Server -> Client
|
||||
|
||||
### @name [String]
|
||||
### @help [String]
|
||||
### @params [String]
|
||||
|
6
docs/v0.0.1/classes/messages/RconCmdRem.md
Normal file
6
docs/v0.0.1/classes/messages/RconCmdRem.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# RconCmdRem
|
||||
|
||||
Server -> Client
|
||||
|
||||
### @name [String]
|
||||
|
5
docs/v0.0.1/classes/messages/ServerInfo.md
Normal file
5
docs/v0.0.1/classes/messages/ServerInfo.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# ServerInfo
|
||||
|
||||
|
||||
|
||||
|
5
docs/v0.0.1/classes/messages/ServerSettings.md
Normal file
5
docs/v0.0.1/classes/messages/ServerSettings.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# ServerSettings
|
||||
|
||||
|
||||
|
||||
|
26
docs/v0.0.1/classes/messages/StartInfo.md
Normal file
26
docs/v0.0.1/classes/messages/StartInfo.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
# StartInfo
|
||||
|
||||
Client -> Server
|
||||
|
||||
### @name [String]
|
||||
### @clan [String]
|
||||
### @country [Integer]
|
||||
### @body [String]
|
||||
### @marking [String]
|
||||
### @decoration [String]
|
||||
### @hands [String]
|
||||
### @feet [String]
|
||||
### @eyes [String]
|
||||
### @custom_color_body [Integer]
|
||||
### @custom_color_marking [Integer]
|
||||
### @custom_color_decoration [Integer]
|
||||
### @custom_color_hands [Integer]
|
||||
### @custom_color_feet [Integer]
|
||||
### @custom_color_eyes [Integer]
|
||||
### @color_body [Integer]
|
||||
### @color_marking [Integer]
|
||||
### @color_decoration [Integer]
|
||||
### @color_hands [Integer]
|
||||
### @color_feet [Integer]
|
||||
### @color_eyes [Integer]
|
||||
|
8
docs/v0.0.1/classes/messages/SvClientDrop.md
Normal file
8
docs/v0.0.1/classes/messages/SvClientDrop.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# SvClientDrop
|
||||
|
||||
Server -> Client
|
||||
|
||||
### @client_id [Integer]
|
||||
### @reason [String]
|
||||
### @silent [Integer]
|
||||
|
109
scripts/messages.sh
Executable file
109
scripts/messages.sh
Executable file
|
@ -0,0 +1,109 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ ! -d spec ]
|
||||
then
|
||||
echo "Error: spec folder not found"
|
||||
echo " run this script from the root of repo"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
arg_generate_docs=0
|
||||
|
||||
for arg in "$@"
|
||||
do
|
||||
if [ "$arg" == "--fix" ] || [ "$arg" == "--generate-docs" ]
|
||||
then
|
||||
arg_generate_docs=1
|
||||
fi
|
||||
done
|
||||
|
||||
function missing_doc() {
|
||||
local rb_file="$1"
|
||||
local version="$2"
|
||||
local line
|
||||
local ifs="$IFS"
|
||||
local dir=''
|
||||
local class_name=''
|
||||
local is_init_raw=0
|
||||
local field
|
||||
local fields=''
|
||||
local dst_file
|
||||
while IFS='' read -r line
|
||||
do
|
||||
if [ "$line" == "# Client -> Server" ]
|
||||
then
|
||||
dir='Client -> Server'
|
||||
elif [ "$line" == "# Server -> Client" ]
|
||||
then
|
||||
dir='Server -> Client'
|
||||
elif [[ "$line" =~ ^class\ ([^ ]+) ]]
|
||||
then
|
||||
class_name="${BASH_REMATCH[1]}"
|
||||
elif [ "$line" == " def init_raw(data)" ]
|
||||
then
|
||||
is_init_raw=1
|
||||
elif [ "$line" == " end" ]
|
||||
then
|
||||
is_init_raw=0
|
||||
fi
|
||||
|
||||
if [ "$is_init_raw" == "1" ]
|
||||
then
|
||||
if [[ "$line" =~ @(.*)\ =\ u.get_string ]]
|
||||
then
|
||||
field="${BASH_REMATCH[1]}"
|
||||
fields+="### @$field [String]\n"
|
||||
elif [[ "$line" =~ @(.*)\ =\ u.get_int ]]
|
||||
then
|
||||
field="${BASH_REMATCH[1]}"
|
||||
fields+="### @$field [Integer]\n"
|
||||
elif [[ "$line" =~ @(.*)\ =\ u.get_raw ]]
|
||||
then
|
||||
field="${BASH_REMATCH[1]}"
|
||||
fields+="### @$field [Raw]\n"
|
||||
fi
|
||||
fi
|
||||
done < "$rb_file"
|
||||
IFS="$ifs"
|
||||
dst_file="docs/$version/classes/messages/$class_name.md"
|
||||
if [ -f "$dst_file" ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
if [ "$arg_generate_docs" == "0" ]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
{
|
||||
echo "# $class_name"
|
||||
echo ''
|
||||
echo "$dir"
|
||||
echo ''
|
||||
echo -e "$fields"
|
||||
} > "$dst_file"
|
||||
return 1
|
||||
}
|
||||
|
||||
function generate_msg_docs() {
|
||||
local version
|
||||
version="$(grep TEEWORLDS_NETWORK_VERSION lib/version.rb | cut -d"'" -f2)"
|
||||
if [ "$version" == "" ]
|
||||
then
|
||||
echo "Error: failed to get library version"
|
||||
exit 1
|
||||
fi
|
||||
local rb_file
|
||||
for rb_file in ./lib/messages/*.rb
|
||||
do
|
||||
echo -n "[*] $(basename "$rb_file") .. "
|
||||
if missing_doc "$rb_file" "$version"
|
||||
then
|
||||
echo "ERROR: missing doc try --fix"
|
||||
else
|
||||
echo "OK"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
generate_msg_docs
|
||||
|
Loading…
Reference in a new issue