[libc][docs] Fix POSIX basedefs links for nested headers (#188738)

Fix broken POSIX basedefs links for nested headers in llvm-libc docs.

The docgen script currently emits paths like `sys/wait.h.html`, but the
Open Group uses `sys_wait.h.html`, for example:
-
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_wait.h.html

This updates nested-header link generation while leaving flat headers
unchanged.
This commit is contained in:
Petter Berntsson 2026-03-27 17:30:43 +00:00 committed by GitHub
parent 22cfe6f39d
commit 2af95b2fa2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -149,6 +149,12 @@ def print_functions_rst(header: Header, functions: Dict):
print(" -")
def posix_basedefs_url(header: Header) -> str:
"""Return the Open Group basedefs URL for a header."""
posix_header_name = header.name.replace("/", "_")
return f"https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/{posix_header_name}.html"
def print_macros_rst(header: Header, macros: Dict):
tbl_hdr = "Macros"
print(tbl_hdr)
@ -170,9 +176,7 @@ def print_macros_rst(header: Header, macros: Dict):
print(" -")
if "in-latest-posix" in macros[name]:
print(
f" - `POSIX.1-2024 <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/{header.name}.html>`__"
)
print(f" - `POSIX.1-2024 <{posix_basedefs_url(header)}>`__")
else:
print(" -")
print()