update-tag-details.sh 1000 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. set -eo pipefail
  3. cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. helperDir='.template-helpers'
  5. # going for "bashbrew: command not found"
  6. bashbrew --help > /dev/null
  7. docker build -t docker-library-docs .
  8. repos=( "$@" )
  9. if [ ${#repos[@]} -eq 0 ]; then
  10. repos=( */ )
  11. fi
  12. repos=( "${repos[@]%/}" )
  13. script="$helperDir/generate-tag-details.pl"
  14. for repo in "${repos[@]}"; do
  15. echo -n "$repo ... "
  16. IFS=$'\n'
  17. tags=( $(bashbrew list "$repo" 2>/dev/null || true) )
  18. unset IFS
  19. if [ "${#tags[@]}" -eq 0 ]; then
  20. echo 'skipping'
  21. continue
  22. fi
  23. {
  24. echo "<!-- THIS FILE IS GENERATED VIA '$script' -->"
  25. echo
  26. echo "# Tags of \`$repo\`"
  27. echo
  28. # add a simple ToC
  29. for tag in "${tags[@]}"; do
  30. # GitHub heading anchors are strange
  31. href="${tag//./}"
  32. href="${href//:/}"
  33. href="#${href,,}"
  34. echo $'-\t[`'"$tag"'`]('"$href"')'
  35. done
  36. docker run -i --rm -v "$PWD":/wtf:ro -w /wtf --entrypoint "$script" docker-library-docs "${tags[@]}"
  37. } > "$repo/tag-details.md"
  38. echo 'done'
  39. done