()
| 139 | |
| 140 | |
| 141 | def main() -> None: |
| 142 | print("Gathering C API names from docs...") |
| 143 | names = set() |
| 144 | for path in C_API_DOCS.glob('**/*.rst'): |
| 145 | text = path.read_text(encoding="utf-8") |
| 146 | for name in API_NAME_REGEX.findall(text): |
| 147 | names.add(name) |
| 148 | print(f"Got {len(names)} names!") |
| 149 | |
| 150 | print("Scanning for undocumented C API functions...") |
| 151 | files = [*INCLUDE.iterdir(), *(INCLUDE / "cpython").iterdir()] |
| 152 | all_missing: list[str] = [] |
| 153 | all_found_ignored: list[str] = [] |
| 154 | |
| 155 | for file in files: |
| 156 | if file.is_dir(): |
| 157 | continue |
| 158 | assert file.exists() |
| 159 | text = file.read_text(encoding="utf-8") |
| 160 | missing, ignored = scan_file_for_docs(str(file.relative_to(INCLUDE)), text, names) |
| 161 | all_found_ignored += ignored |
| 162 | all_missing += missing |
| 163 | |
| 164 | fail = False |
| 165 | to_check = [ |
| 166 | (all_missing, "missing", found_undocumented(len(all_missing) == 1)), |
| 167 | ( |
| 168 | all_found_ignored, |
| 169 | "documented but ignored", |
| 170 | found_ignored_documented(len(all_found_ignored) == 1), |
| 171 | ), |
| 172 | ] |
| 173 | for name_list, what, message in to_check: |
| 174 | if not name_list: |
| 175 | continue |
| 176 | |
| 177 | s = "s" if len(name_list) != 1 else "" |
| 178 | print(f"-- {len(name_list)} {what} C API{s} --") |
| 179 | for name in name_list: |
| 180 | print(f" - {name}") |
| 181 | print(message) |
| 182 | fail = True |
| 183 | |
| 184 | sys.exit(1 if fail else 0) |
| 185 | |
| 186 | |
| 187 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…