gen-doc.sh 683 B

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