generate_documentation.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/bash
  2. POSIXLY_CORRECT=1
  3. CHECK_API=false
  4. GEN_HTML=false
  5. GEN_PDF=false
  6. GEN_ALL=false
  7. INSTALL_DOX=false
  8. command -v g++
  9. if [ $? -ne "0" ]; then
  10. echo "Please install g++"
  11. exit 1
  12. fi
  13. command -v cmake
  14. if [ $? -ne "0" ]; then
  15. echo "Please install cmake"
  16. exit 1
  17. fi
  18. command -v git
  19. if [ $? -ne "0" ]; then
  20. echo "Please install git"
  21. exit 1
  22. fi
  23. command -v make
  24. if [ $? -ne "0" ]; then
  25. echo "Please install make"
  26. exit 1
  27. fi
  28. # Checking arguments and setting appropriate option variables
  29. for var in "$@"
  30. do
  31. case $var in
  32. -install)
  33. INSTALL_DOX=true
  34. ;;
  35. -html)
  36. CHECK_API=true
  37. GEN_HTML=true
  38. ;;
  39. -pdf)
  40. CHECK_API=true
  41. GEN_PDF=true
  42. ;;
  43. -all)
  44. CHECK_API=true
  45. GEN_ALL=true
  46. ;;
  47. esac
  48. done
  49. # Checking if doxygen is already installed
  50. # True - doxygen from "which doxygen" is used to generate documentation
  51. # False - clones doxygen Release_1_8_13 and ./build/bin/ added to PATH
  52. if [ $INSTALL_DOX = true ] && [ ! "$(which doxygen)" ]; then
  53. mkdir -p build
  54. cd build
  55. echo "cloning doxygen 1.8.13..."
  56. git clone --depth 1 --branch Release_1_8_13 https://github.com/doxygen/doxygen
  57. cmake -G "Unix Makefiles" doxygen/
  58. make
  59. cd ..
  60. export PATH="./build/bin/:$PATH"
  61. fi
  62. # Runs script to check that all API with documentation match wolfSSL API
  63. if [ $CHECK_API = true ]; then
  64. ./check_api.sh
  65. fi
  66. if [ $? = 1 ]; then
  67. echo "Not all API match"
  68. exit 1
  69. fi
  70. #HTML GENERATION
  71. if [ $GEN_HTML = true ] || [ $GEN_ALL = true ]; then
  72. cp -r formats/html/* ./
  73. echo "generating html..."
  74. doxygen Doxyfile
  75. cp html_changes/search/* html/search/
  76. cp html_changes/*.css html/
  77. cp html_changes/*.js html/
  78. rm footer.html header.html
  79. rm -rf html_changes
  80. rm mainpage.dox
  81. rm Doxyfile
  82. echo "finished generating html..."
  83. echo "To view the html files use a browser to open the index.html file located at doc/html/index.html"
  84. fi
  85. #PDF GENERATION
  86. if [ $GEN_PDF = true ] || [ $GEN_ALL = true ]; then
  87. cp -r formats/pdf/* ./
  88. echo "generating pdf..."
  89. doxygen Doxyfile
  90. cd latex/
  91. make
  92. mv refman.pdf ../
  93. cd ..
  94. rm -rf latex/
  95. rm Doxyfile
  96. rm header.tex
  97. echo "finished generating pdf..."
  98. fi