From 0fbda526d0887e83d8dc43c9528a10a8cb5b80ad Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 28 Oct 2018 02:00:06 +0200 Subject: [PATCH] Added script for generating docs for newly added files --- generate_missing_docs.sh | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 generate_missing_docs.sh diff --git a/generate_missing_docs.sh b/generate_missing_docs.sh new file mode 100755 index 0000000000..bb4c755cda --- /dev/null +++ b/generate_missing_docs.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +latest_docs_commit=$(git log ./docs | head -1 | cut -d' ' -f 2) +code_dirs='platypush/plugins platypush/backend platypush/message/event' +target_dir='docs/source/platypush' + +git diff --name-status $latest_docs_commit..HEAD $code_dirs \ + | grep '^A' | grep '\.py$' | awk '{print $2}' | while read filename; do + + module_name=$(echo -n $filename | sed -r -e 's/(.*)\.py$/\1/' | tr '/' '.') + + case $filename in + platypush/backend/*) + target_file="$target_dir/backend/$(echo -n $filename | sed -r -e 's/^platypush\/backend\/(.*)\.py$/\1.rst/' | tr '/' '.')" + ;; + platypush/plugins/*) + target_file="$target_dir/plugins/$(echo -n $filename | sed -r -e 's/^platypush\/plugins\/(.*)\.py$/\1.rst/' | tr '/' '.')" + ;; + platypush/message/event/*) + target_file="$target_dir/events/$(echo -n $filename | sed -r -e 's/^platypush\/message\/event\/(.*)\.py$/\1.rst/' | tr '/' '.')" + ;; + esac + + backticks='``' + header_top="$backticks$module_name$backticks" + echo "$header_top" > "$target_file" + perl -e "print '=' x length('$header_top')" >> "$target_file" + echo >> "$target_file" + echo >> "$target_file" + echo ".. automodule:: $module_name" >> "$target_file" + echo -e "\t:members:" >> $target_file + echo >> "$target_file" + + case $filename in + platypush/backend/*) + index_file="$target_dir/../backends.rst" + header=$(cat $index_file | head -8) + files=$(find docs/source/platypush/backend -type f -name '*.rst' | sort | sed -r -e 's/^docs\/source\/(.*)$/ \1/') + echo $"$header" > $index_file + echo $"$files" >> $index_file + ;; + platypush/plugins/*) + index_file="$target_dir/../plugins.rst" + header=$(cat $index_file | head -7) + files=$(find docs/source/platypush/plugins -type f -name '*.rst' | sort | sed -r -e 's/^docs\/source\/(.*)$/ \1/') + echo $"$header" > $index_file + echo >> $index_file + echo $"$files" >> $index_file + ;; + platypush/message/event/*) + index_file="$target_dir/../events.rst" + header=$(cat $index_file | head -7) + files=$(find docs/source/platypush/events -type f -name '*.rst' | sort | sed -r -e 's/^docs\/source\/(.*)$/ \1/') + echo $"$header" > $index_file + echo >> $index_file + echo $"$files" >> $index_file + ;; + esac +done +