generateDocList.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # start script from it's folder
  3. cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null || exit
  4. # Standard file locations
  5. homedir='../../'
  6. . ../env.sh
  7. ## Generate Doc Table
  8. unset table
  9. nDocs=$( jq '.docs | length' "$appinfo")
  10. for doc in $(seq 0 $(( nDocs - 1 ))); do
  11. info=$( jq ".docs | sort_by(.File | ascii_upcase) | .[$doc]" "$appinfo" )
  12. # Get Doc Path
  13. FILE=$( echo "$info" | jq '.File' | tr -d '"' )
  14. # Get Doc Description
  15. DESC=$( echo "$info" | jq '.Description' | tr -d '"' )
  16. # YouTube Video
  17. YT=$( jq ".youtube[] | select(.Doc==\"$FILE\") | .URL" "$appinfo" )
  18. [ "$YT" != "" ] && YT="[![YouTube](https://img.shields.io/badge/YouTube-FF0000?style=plastic&logo=youtube&logoColor=white)]($YT)"
  19. # Apps
  20. APPS=$( grep -RlZ "$FILE" "$appsfolder" | xargs -0 jq '.title' | tr -d '"' | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/<br>/g' )
  21. line="|[$FILE]($Docs$FILE)|$DESC|$APPS|$YT|"
  22. if [ "$doc" == "0" ] ; then
  23. table=$line
  24. else
  25. table=$( echo -e "$table\n$line")
  26. fi
  27. done
  28. cp -f "$DocList_TEMPLATE" "$DocList"
  29. echo -e "$table" >> "$DocList"