check_doc_warnings.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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~${IDF_PATH}~\${IDF_PATH}~" | \
  20. sed -E "s/:[0-9]+:/:line:/" > sphinx-warning-log-sanitized.txt
  21. # diff sanitized warnings, ignoring lines which only appear in ../sphinx-known-warnings.txt
  22. # format is to display only lines new or changed in second argument
  23. DIFF_FORMAT="--unchanged-line-format= --old-line-format= --new-line-format=%L"
  24. SPHINX_WARNINGS=$(diff $DIFF_FORMAT ../sphinx-known-warnings.txt sphinx-warning-log-sanitized.txt)
  25. if ! [ -z "$SPHINX_WARNINGS" ]; then
  26. echo "$STARS"
  27. echo "Build failed due to new/different Sphinx warnings:"
  28. echo "$SPHINX_WARNINGS"
  29. echo "$STARS"
  30. RESULT=1
  31. echo "(Check files ../sphinx-known-warnings.txt and sphinx-warning-log.txt for full details.)"
  32. fi
  33. exit $RESULT