MCPcopy Index your code
hub / github.com/python/cpython / main

Function main

Tools/check-c-api-docs/main.py:141–184  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

139
140
141def 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
187if __name__ == "__main__":

Callers 1

main.pyFile · 0.70

Calls 14

setFunction · 0.85
scan_file_for_docsFunction · 0.85
strFunction · 0.85
found_undocumentedFunction · 0.85
found_ignored_documentedFunction · 0.85
globMethod · 0.45
read_textMethod · 0.45
findallMethod · 0.45
addMethod · 0.45
iterdirMethod · 0.45
is_dirMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…