check_documentation.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/usr/bin/env python2.7
  2. # Copyright 2015 gRPC authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # check for directory level 'README.md' files
  16. # check that all implementation and interface files have a \file doxygen comment
  17. import os
  18. import sys
  19. # where do we run
  20. _TARGET_DIRS = [
  21. 'include/grpc', 'include/grpc++', 'src/core', 'src/cpp', 'test/core',
  22. 'test/cpp'
  23. ]
  24. # which file extensions do we care about
  25. _INTERESTING_EXTENSIONS = ['.c', '.h', '.cc']
  26. # find our home
  27. _ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..'))
  28. os.chdir(_ROOT)
  29. errors = 0
  30. # walk directories, find things
  31. printed_banner = False
  32. for target_dir in _TARGET_DIRS:
  33. for root, dirs, filenames in os.walk(target_dir):
  34. if 'README.md' not in filenames:
  35. if not printed_banner:
  36. print('Missing README.md')
  37. print('=================')
  38. printed_banner = True
  39. print(root)
  40. errors += 1
  41. if printed_banner:
  42. print()
  43. printed_banner = False
  44. for target_dir in _TARGET_DIRS:
  45. for root, dirs, filenames in os.walk(target_dir):
  46. for filename in filenames:
  47. if os.path.splitext(filename)[1] not in _INTERESTING_EXTENSIONS:
  48. continue
  49. path = os.path.join(root, filename)
  50. with open(path) as f:
  51. contents = f.read()
  52. if '\\file' not in contents:
  53. if not printed_banner:
  54. print('Missing \\file comment')
  55. print('======================')
  56. printed_banner = True
  57. print(path)
  58. errors += 1
  59. assert errors == 0, 'error count = %d' % errors