generateDocList.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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) | .[$doc]" "$appinfo" )
  12. # Get Doc ID
  13. ID=$( echo "$info" | jq '.ID' | tr -d '"' )
  14. # Get Doc Path
  15. FILE=$( echo "$info" | jq '.File' | tr -d '"' )
  16. # Get Doc Description
  17. DESC=$( echo "$info" | jq '.Description' | tr -d '"' )
  18. # YouTube Video
  19. YT=$( jq ".youtube[] | select(.DocID==$ID) | .URL" "$appinfo" )
  20. [ "$YT" != "" ] && YT="[![YouTube](https://img.shields.io/badge/YouTube-FF0000?style=plastic&logo=youtube&logoColor=white)]($YT)"
  21. # Apps
  22. APPS=$( jq ".apps[] | select(.DocID==$ID) | .Title" "$appinfo" | tr -d '"' )
  23. if [ "$APPS" != "" ] && [ "$( echo "$APPS" | wc -l)" -gt "1" ] ; then
  24. unset temp_app
  25. while IFS="" read -r app || [ -n "$app" ]
  26. do
  27. if [ -z "$temp_app" ] ; then
  28. temp_app="$app"
  29. else
  30. temp_app="$temp_app<br>$app"
  31. fi
  32. done < <( echo "$APPS" )
  33. APPS="$temp_app"
  34. fi
  35. line="|[$FILE]($Docs$FILE)|$DESC|$APPS|$YT|"
  36. if [ "$doc" == "0" ] ; then
  37. table=$line
  38. else
  39. table=$( echo -e "$table\n$line")
  40. fi
  41. done
  42. cp -f "$DocList_TEMPLATE" "$DocList"
  43. echo -e "$table" >> "$DocList"