mfdoc 953 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env bash
  2. #
  3. # mfdoc
  4. #
  5. # Start Jekyll in watch mode to work on Marlin Documentation and preview locally
  6. #
  7. [[ $# == 0 ]] || { echo "usage: `basename $0`" 1>&2 ; exit 1; }
  8. MFINFO=$(mfinfo "$@") || exit 1
  9. IFS=' ' read -a INFO <<< "$MFINFO"
  10. ORG=${INFO[0]}
  11. REPO=${INFO[2]}
  12. BRANCH=${INFO[5]}
  13. [[ $ORG == "MarlinFirmware" && $REPO == "MarlinDocumentation" ]] || { echo "Wrong repository." 1>&2; exit 1; }
  14. opensite() {
  15. which xdg-open >/dev/null && TOOL=xdg-open
  16. which gnome-open >/dev/null && TOOL=gnome-open
  17. which open >/dev/null && TOOL=open
  18. URL="http://127.0.0.1:4000/"
  19. if [ -z "$OPEN" ]; then
  20. echo "Can't find a tool to open the URL:"
  21. echo $URL
  22. else
  23. echo "Opening preview site in the browser..."
  24. "$OPEN" "$URL"
  25. fi
  26. }
  27. echo "Previewing MarlinDocumentation..."
  28. bundle exec jekyll serve --watch --incremental | {
  29. while IFS= read -r line
  30. do
  31. [[ $line =~ "Server running" ]] && opensite
  32. echo "$line"
  33. done
  34. }