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 20import os 21import sys 22 23# where do we run 24_TARGET_DIRS = [ 25 "include/grpc", 26 "include/grpc++", 27 "src/core", 28 "src/cpp", 29 "test/core", 30 "test/cpp", 31] 32 33# which file extensions do we care about 34_INTERESTING_EXTENSIONS = [".c", ".h", ".cc"] 35 36# find our home 37_ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../../..")) 38os.chdir(_ROOT) 39 40errors = 0 41 42# walk directories, find things 43printed_banner = False 44for target_dir in _TARGET_DIRS: 45 for root, dirs, filenames in os.walk(target_dir): 46 if "README.md" not in filenames: 47 if not printed_banner: 48 print("Missing README.md") 49 print("=================") 50 printed_banner = True 51 print(root) 52 errors += 1 53if printed_banner: 54 print() 55printed_banner = False 56for target_dir in _TARGET_DIRS: 57 for root, dirs, filenames in os.walk(target_dir): 58 for filename in filenames: 59 if os.path.splitext(filename)[1] not in _INTERESTING_EXTENSIONS: 60 continue 61 path = os.path.join(root, filename) 62 with open(path) as f: 63 contents = f.read() 64 if "\\file" not in contents: 65 if not printed_banner: 66 print("Missing \\file comment") 67 print("======================") 68 printed_banner = True 69 print(path) 70 errors += 1 71 72assert errors == 0, "error count = %d" % errors 73