diff --git a/docs/v0.0.1/README.md b/docs/v0.0.1/README.md index e4ec6d8..c54e5ee 100644 --- a/docs/v0.0.1/README.md +++ b/docs/v0.0.1/README.md @@ -1,17 +1,20 @@ + + # teeworlds_network Version v0.0.1 ## Classes -### [ChatMessage](classes/ChatMessage.md) -### [Snapshot](classes/Snapshot.md) +### [ChatMessage](classes/ChatMessage.md) ### [Context](classes/Context.md) ### [Player](classes/Player.md) +### [Snapshot](classes/Snapshot.md) + ### [TeeworldsClient](classes/TeeworldsClient.md) [#on_disconnect(&block)](classes/TeeworldsClient.md#on_disconnect) diff --git a/scripts/update_docs_index.sh b/scripts/update_docs_index.sh index 59c7b5c..a126403 100755 --- a/scripts/update_docs_index.sh +++ b/scripts/update_docs_index.sh @@ -9,6 +9,14 @@ fi tmpdir=scripts/tmp mkdir -p scripts/tmp +tmpfile="$tmpdir/README.md" + +version="$(grep TEEWORLDS_NETWORK_VERSION lib/version.rb | cut -d"'" -f2)" +if [ "$version" == "" ] +then + echo "Error: failed to get library version" + exit 1 +fi arg_generate_docs=0 @@ -23,42 +31,48 @@ do fi done -function print_hooks() { - local version="$1" +function print_instance_methods() { + local class="$1" local hook local hook_slug while read -r hook do hook_slug="${hook%%(*}" echo "" - echo "[#$hook](classes/TeeworldsClient.md#$hook_slug)" - done < <(grep '###' "docs/$version/classes/TeeworldsClient.md" | cut -d'#' -f5) + echo "[#$hook](classes/$class.md#$hook_slug)" + done < <(grep '### > "$tmpfile" + done +} + +function check_diff_or_fix() { local index_file="docs/$version/README.md" if [ ! -f "$index_file" ] then echo "Error: missing index file $index_file" exit 1 fi - local tmpfile="$tmpdir/README.md" - { - awk '1;/TeeworldsClient/{exit}' "$index_file" - print_hooks "$version" - } > "$tmpfile" if [ "$arg_generate_docs" == "1" ] then mv "$tmpfile" "$index_file" return fi local diff - if ! diff="$(diff "$tmpfile" "$index_file")" - then - echo "Error: failed to check diff" - exit 1 - fi + echo "$tmpfile" "$index_file" + diff="$(diff "$tmpfile" "$index_file")" if [ "$diff" != "" ] then echo "Error: documentation index is not up to date" @@ -70,14 +84,19 @@ function gen_doc_index() { } function main() { - 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 - gen_doc_index "$version" + cat <<- EOF > "$tmpfile" + + + # teeworlds_network + + Version $version + + ## Classes + + EOF + list_classes + check_diff_or_fix } main +