[libc-commits] [libc] [libc][docs] adds macro handling, POSIX status, and validation to docgen (PR #89421)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Mon Apr 22 12:57:45 PDT 2024


================
@@ -73,10 +172,78 @@ def print_header(header: str, api: Dict):
 
   * - Function
     - Implemented
-    - Standard"""
+    - C Standard
+    - POSIX Standard"""
     )
-    # TODO: how do we want to signal implementation of macros?
-    print_functions(header, api["functions"])
+
+
+def print_functions_rst(header: Header, functions: Dict):
+    tbl_hdr = "Functions"
+    print(tbl_hdr)
+    print("=" * len(tbl_hdr))
+
+    print_tbl_dir()
+
+    for name in sorted(functions.keys()):
+        print(f"  * - {name}")
+
+        if header.fns_dir_exists() and header.implements_fn(name):
+            print("    - |check|")
+        else:
+            print("    -")
+
+        if "c-definition" in functions[name]:
+            print(f'    - {functions[name]["c-definition"]}')
+        else:
+            print("    -")
+
+        if "posix-definition" in functions[name]:
+            print(f'    - {functions[name]["posix-definition"]}')
+        else:
+            print("    -")
+
+
+def print_macros_rst(header: Header, macros: Dict):
+    tbl_hdr = "Macros"
+    print(tbl_hdr)
+    print("=" * len(tbl_hdr))
+
+    print_tbl_dir()
+
+    for name in sorted(macros.keys()):
+        print(f"  * - {name}")
+
+        if header.macro_file_exists() and header.implements_macro(name):
+            print("    - |check|")
+        else:
+            print("    -")
+
+        if "c-definition" in macros[name]:
+            print(f'    - {macros[name]["c-definition"]}')
+        else:
+            print("    -")
+
+        if "posix-definition" in macros[name]:
+            print(f'    - {macros[name]["posix-definition"]}')
+        else:
+            print("    -")
+
+
+def print_impl_status_rst(header: Header, api: Dict):
+    print(".. include:: check.rst\n")
+
+    print("=" * len(header.name))
+    print(header.name)
+    print("=" * len(header.name))
+    print()
+
+    # the macro and function sections are both optional
+    if "macros" in api:
+        print_macros_rst(header, api["macros"])
+        print()
----------------
nickdesaulniers wrote:

move this print into print_macros_rst?

https://github.com/llvm/llvm-project/pull/89421


More information about the libc-commits mailing list