diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2020-05-12 17:15:28 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2020-05-12 17:28:24 -0700 |
| commit | 4e8de3c554024d3ac89e9ee77b958a6932a64bec (patch) | |
| tree | 4606c0cf69cef8a033aa2d95fab0811ddf49123a /tools | |
| parent | c534a872a2b5a2d5e6b7543f56539afb24261443 (diff) | |
Swap sphinx to autoapi and the inline stubs
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/extract_pyi.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index de783eb27..95370f761 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -22,7 +22,7 @@ for module in modules: pyi_lines = [] classes = os.listdir(module_path) classes = [x for x in sorted(classes) if x.endswith(".c")] - if classes[-1] == "__init__.c": + if classes and classes[-1] == "__init__.c": classes.insert(0, classes.pop()) for class_file in classes: class_path = os.path.join(module_path, class_file) @@ -37,6 +37,13 @@ for module in modules: continue pyi_lines.append(line) + raw_stubs = [x for x in sorted(classes) if x.endswith(".pyi")] + if raw_stubs and raw_stubs[-1] == "__init__.pyi": + raw_stubs.insert(0, raw_stubs.pop()) + for raw_stub in raw_stubs: + raw_stub_path = os.path.join(module_path, raw_stub) + with open(raw_stub_path, "r") as f: + pyi_lines.extend(f.readlines()) stub_filename = os.path.join(stub_directory, module + ".pyi") print(stub_filename) stub_contents = "".join(pyi_lines) @@ -54,3 +61,6 @@ for module in modules: print() print(f"{ok} ok out of {total}") + +if ok != total: + sys.exit(total - ok) |
