No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

generate_docs.sh 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. # SPDX-FileCopyrightText: 2023 - 2024 Thomas Buck <thomas@xythobuz.de>
  3. # SPDX-License-Identifier: CERN-OHL-S-2.0+
  4. #
  5. # ------------------------------------------------------------------------------
  6. # | Copyright (c) 2023 - 2024 Thomas Buck <thomas@xythobuz.de> |
  7. # | |
  8. # | This source describes Open Hardware and is licensed under the CERN-OHL-S v2 |
  9. # | or any later version. |
  10. # | |
  11. # | You may redistribute and modify this source and make products using it under |
  12. # | the terms of the CERN-OHL-S v2 (https://ohwr.org/cern_ohl_s_v2.txt) |
  13. # | or any later version. |
  14. # | |
  15. # | This source is distributed WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, |
  16. # | INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY AND FITNESS FOR A |
  17. # | PARTICULAR PURPOSE. Please see the CERN-OHL-S v2 (or any later version) |
  18. # | for applicable conditions. |
  19. # | |
  20. # | Source location: https://github.com/drinkrobotics/dispensy |
  21. # | |
  22. # | As per CERN-OHL-S v2 section 4, should You produce hardware based on this |
  23. # | source, You must where practicable maintain the Source Location visible |
  24. # | on the external case of the Gizmo or other products you make using this |
  25. # | source. |
  26. # ------------------------------------------------------------------------------
  27. cd "$(dirname "$0")"
  28. echo "Generating plots"
  29. rm -rf src/plot
  30. ../hardware/generate_plot.sh
  31. cp -r ../hardware/plot src
  32. echo "Generating plot includes"
  33. rm -rf src/inc_dispensy_sch.md
  34. echo "<script src=\"js/svg-pan-zoom.js\" charset=\"UTF-8\"></script>" >> src/inc_dispensy_sch.md
  35. for f in `ls src/plot/dispensy_sch.svg/*.svg | sort -r`; do
  36. file=`echo $f | sed 's:src/:./:g'`
  37. name=`echo $f | sed 's:src/plot/dispensy_sch.svg/::g' | sed 's:.svg::g'`
  38. echo $name
  39. echo "<h2>$name</h2>" >> src/inc_dispensy_sch.md
  40. echo "<div style=\"background-color: white;\">" >> src/inc_dispensy_sch.md
  41. echo "<embed type=\"image/svg+xml\" src=\"$file\" id=\"pz_$name\" style=\"width:100%;\"/>" >> src/inc_dispensy_sch.md
  42. echo "<script>" >> src/inc_dispensy_sch.md
  43. echo "document.getElementById('pz_$name').addEventListener('load', function(){" >> src/inc_dispensy_sch.md
  44. echo "svgPanZoom(document.getElementById('pz_$name'), {controlIconsEnabled: true});" >> src/inc_dispensy_sch.md
  45. echo "})" >> src/inc_dispensy_sch.md
  46. echo "</script>" >> src/inc_dispensy_sch.md
  47. echo "</div>" >> src/inc_dispensy_sch.md
  48. echo >> src/inc_dispensy_sch.md
  49. done
  50. echo "Generating docs"
  51. if [ "$1" = "serve" ] ; then
  52. mdbook serve --open
  53. elif [ "$1" = "build" ] ; then
  54. mdbook build
  55. else
  56. echo "Invalid command. 'build' or 'serve'."
  57. fi