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

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.
This commit is contained in:
Jeff Bailey 2026-03-27 22:19:29 +00:00 committed by GitHub
parent 0aba82eb70
commit d6ff5e7778
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,6 +43,10 @@ class Header:
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,17 @@ class Header:
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 +90,15 @@ class Header:
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]: