verify-reference-index.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. RETVAL=0
  3. verify_index() {
  4. retval=0
  5. for refdir in $*; do
  6. verify_modules_in_index "$refdir/index.rst"
  7. verify_files "$refdir"
  8. done
  9. return $RETVAL
  10. }
  11. verify_files() {
  12. for path in $1/*.rst; do
  13. rst=${path##*/}
  14. modname=${rst%*.rst}
  15. if [ $modname != "index" ]; then
  16. modpath=$(echo $modname | tr . /)
  17. pkg="$modpath/__init__.py"
  18. mod="$modpath.py"
  19. if [ ! -f "$pkg" ]; then
  20. if [ ! -f "$mod" ]; then
  21. echo "*** NO MODULE $modname for reference '$path'"
  22. RETVAL=1
  23. fi
  24. fi
  25. fi
  26. done
  27. }
  28. verify_modules_in_index() {
  29. modules=$(grep "celery." "$1" | \
  30. perl -ple's/^\s*|\s*$//g;s{\.}{/}g;')
  31. for module in $modules; do
  32. if [ ! -f "$module.py" ]; then
  33. if [ ! -f "$module/__init__.py" ]; then
  34. echo "*** IN INDEX BUT NO MODULE: $module"
  35. RETVAL=1
  36. fi
  37. fi
  38. done
  39. }
  40. verify_index docs/reference docs/internals/reference