check_doc_warnings.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. #
  3. # Check for Documentation warnings:
  4. # doxygen-warning-log.txt should be an empty file
  5. # sphinx-warning-log.txt should only contain (fuzzy) matches to ../sphinx-known-warnings.txt
  6. RESULT=0
  7. STARS='***************************************************'
  8. if [ -s doxygen-warning-log.txt ]; then
  9. echo "$STARS"
  10. echo "Build failed due to doxygen warnings:"
  11. cat doxygen-warning-log.txt
  12. echo "$STARS"
  13. RESULT=1
  14. fi
  15. # Remove escape characters, file paths, line numbers from
  16. # the Sphinx warning log
  17. # (escape char removal from https://www.commandlinefu.com/commands/view/6141/remove-color-codes-special-characters-with-sed
  18. sed -r 's:\x1B\[[0-9;]*[mK]::g' sphinx-warning-log.txt | \
  19. sed -E "s/.*\/(.*):[0-9]+:/\1:line:/" > sphinx-warning-log-sanitized.txt
  20. # diff sanitized warnings, ignoring lines which only appear in ../sphinx-known-warnings.txt
  21. # format is to display only lines new or changed in second argument
  22. DIFF_FORMAT="--unchanged-line-format= --old-line-format= --new-line-format=%L"
  23. SPHINX_WARNINGS=$(diff $DIFF_FORMAT ../sphinx-known-warnings.txt sphinx-warning-log-sanitized.txt)
  24. if ! [ -z "$SPHINX_WARNINGS" ]; then
  25. echo "$STARS"
  26. echo "Build failed due to new/different Sphinx warnings:"
  27. echo "$SPHINX_WARNINGS"
  28. echo "$STARS"
  29. RESULT=1
  30. echo "(Check files ../sphinx-known-warnings.txt and sphinx-warning-log.txt for full details.)"
  31. fi
  32. exit $RESULT