gen-doc.sh 767 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/sh
  2. #
  3. # Generate documentation
  4. #
  5. basedir="$(dirname "$0")"
  6. [ "$(echo "$basedir" | cut -c1)" = '/' ] || basedir="$PWD/$basedir"
  7. srcdir="$basedir/.."
  8. die()
  9. {
  10. echo "$*" >&2
  11. exit 1
  12. }
  13. gen()
  14. {
  15. local rst="$1"
  16. local docname="$(basename "$rst" .rst)"
  17. local dir="$(dirname "$rst")"
  18. local html="$dir/$docname.html"
  19. echo "Generating $(realpath --relative-to="$srcdir" "$html") from $(realpath --relative-to="$srcdir" "$rst") ..."
  20. python3 -m readme_renderer -o "$html" "$rst" ||\
  21. die "Failed to generate"
  22. }
  23. for i in $(find "$srcdir" \( -name submodules -prune \) -o \( -name release-archives -prune \) -o \( -name build -prune \) -o \( -name toolchain-build -prune \) -o \( -name crcgen -prune \) -o \( -name '*.rst' -print \)); do
  24. gen "$i"
  25. done
  26. exit 0