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