1#!/usr/bin/env python3 2# Copyright (C) 2022 The Android Open Source Project 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 16# This tool checks that every SQL object created without prefix 17# 'internal_' is documented with proper schema. 18 19from __future__ import absolute_import 20from __future__ import division 21from __future__ import print_function 22 23import os 24import sys 25 26ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 27sys.path.append(os.path.join(ROOT_DIR)) 28FILE_DIR = ROOT_DIR 29 30from python.generators.stdlib_docs.stdlib import * 31 32 33def main(): 34 35 errors = [] 36 metrics_sources = os.path.join(FILE_DIR, "src", "trace_processor", "stdlib") 37 for root, _, files in os.walk(metrics_sources, topdown=True): 38 for f in files: 39 path = os.path.join(root, f) 40 if path.endswith(".sql"): 41 with open(path) as f: 42 sql = f.read() 43 errors += parse_file_to_dict(path, sql)[1] 44 sys.stderr.write("\n\n".join(errors)) 45 return 0 if not errors else 1 46 47 48if __name__ == "__main__": 49 sys.exit(main()) 50