build.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. # Use this script to build YDB docs with open-source tools and start an HTTP server
  3. # You may specify the output directory as a parameter. If omitted, the docs will be generated to a TEMP subdirectory
  4. set -e
  5. check_dependency() {
  6. if ! command -v $1 &> /dev/null; then
  7. echo
  8. echo "You need to have $2 installed to run this script, exiting"
  9. echo "Installation instructions: $3"
  10. exit 1
  11. fi
  12. }
  13. start_server() {
  14. echo
  15. echo "Starting HTTP server, open the links in your browser:"
  16. echo
  17. echo "- http://localhost:8888/en (English)"
  18. echo "- http://localhost:8888/ru (Russian)"
  19. echo
  20. echo "Press Ctrl+C in this window to stop the HTTP server."
  21. echo
  22. python3 -m http.server 8888 -d $1
  23. }
  24. DIR=${1:-"$TMPDIR"docs}
  25. check_dependency "yfm" "YFM builder" "https://diplodoc.com/docs/en/tools/docs/"
  26. check_dependency "python3" "Python3" "https://www.python.org/downloads/"
  27. echo "Starting YFM builder"
  28. echo "Output directory: $DIR"
  29. if ! yfm -i . -o $DIR --allowHTML --apply-presets; then
  30. echo
  31. echo '================================'
  32. echo 'YFM build completed with ERRORS!'
  33. echo '================================'
  34. echo 'It may be necessary to use the latest version of npm. Run the commands `nvm install v23.7.0` and `nvm use v23.7.0` to update it.'
  35. exit 1
  36. fi
  37. start_server $DIR