[libc-commits] [libc] [libc][docs] Parse inline macro_value from YAML in docgen (PR #189118)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Fri Mar 27 14:57:49 PDT 2026


https://github.com/kaladron updated https://github.com/llvm/llvm-project/pull/189118

>From 0d3cc9daaecc032b2d37d7c1e322585af5cf737b Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Fri, 27 Mar 2026 21:23:11 +0000
Subject: [PATCH] [libc][docs] Parse inline macro_value from YAML in docgen

The docgen script was previously hardcoded to assume all implemented
macros must be placed in a *-macros.h header. This updates docgen to
read inline macro_value properties directly from the source YAML files,
correctly recognizing them as implemented.
---
 libc/utils/docgen/header.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/libc/utils/docgen/header.py b/libc/utils/docgen/header.py
index 5bf524a64b69b..66312ac6aa11d 100644
--- a/libc/utils/docgen/header.py
+++ b/libc/utils/docgen/header.py
@@ -43,6 +43,10 @@ def __init__(self, header_name: str):
         self.docgen_root = Path(__file__).parent
         self.libc_root = self.docgen_root.parent.parent
         self.docgen_yaml = self.docgen_root / Path(header_name).with_suffix(".yaml")
+        # Path to libc/include/<name>.yaml
+        self.include_yaml = Path(
+            self.libc_root, "include", Path(header_name).with_suffix(".yaml")
+        )
         self.fns_dir = Path(self.libc_root, "src", self.stem)
         self.macros_dir = Path(self.libc_root, "include", "llvm-libc-macros")
 
@@ -50,6 +54,16 @@ def macro_file_exists(self) -> bool:
         for _ in self.__get_macro_files():
             return True
 
+        if self.include_yaml.exists():
+            import yaml
+            parsed = yaml.safe_load(self.include_yaml.read_text(encoding="utf-8"))
+            if (
+                parsed
+                and "macros" in parsed
+                and any("macro_value" in m for m in parsed["macros"])
+            ):
+                return True
+
         return False
 
     def fns_dir_exists(self) -> bool:
@@ -75,6 +89,15 @@ def implements_macro(self, m_name: str) -> bool:
             if f"#define {m_name}" in f.read_text():
                 return True
 
+        if self.include_yaml.exists():
+            import yaml
+
+            parsed = yaml.safe_load(self.include_yaml.read_text(encoding="utf-8"))
+            if parsed and "macros" in parsed:
+                for macro in parsed["macros"]:
+                    if macro.get("macro_name") == m_name and "macro_value" in macro:
+                        return True
+
         return False
 
     def __get_macro_files(self) -> Generator[Path, None, None]:



More information about the libc-commits mailing list