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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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; border: 1px solid black;\">" >> 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, minZoom: 1.0});" >> 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. echo "[Direct link to \`$name\`]($file)." >> src/inc_dispensy_sch.md
  50. echo >> src/inc_dispensy_sch.md
  51. done
  52. echo "Preparing modelview dependencies"
  53. cd modelview
  54. sed -i 's/info\.inner/info_elem\.inner/g' modelview.js
  55. ./fetch_deps.sh
  56. cd ..
  57. rm -rf src/js/deps
  58. cp -r modelview/deps src/js
  59. echo "Generating docs"
  60. if [ "$1" = "serve" ] ; then
  61. mdbook serve --open
  62. elif [ "$1" = "build" ] ; then
  63. mdbook build
  64. else
  65. echo "Invalid command. 'build' or 'serve'."
  66. fi