mfdoc 892 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. URL="http://127.0.0.1:4000/"
  16. OPEN=$(echo $(which gnome-open xdg-open open) | awk '{ print $1 }')
  17. if [ -z "$OPEN" ]; then
  18. echo "Can't find a tool to open the URL:"
  19. echo $URL
  20. else
  21. echo "Opening preview site in the browser..."
  22. "$OPEN" "$URL"
  23. fi
  24. }
  25. echo "Previewing MarlinDocumentation..."
  26. bundle exec jekyll serve --watch --incremental | {
  27. while IFS= read -r line
  28. do
  29. [[ $line =~ "Server running" ]] && opensite
  30. echo "$line"
  31. done
  32. }