Skip to content

[libc][docs] Fix docgen macro lookup for underscored headers#194367

Merged
michaelrj-google merged 1 commit into
llvm:mainfrom
petbernt:libc-docs-fix-docgen-underscored-headers
Apr 30, 2026
Merged

[libc][docs] Fix docgen macro lookup for underscored headers#194367
michaelrj-google merged 1 commit into
llvm:mainfrom
petbernt:libc-docs-fix-docgen-underscored-headers

Conversation

@petbernt
Copy link
Copy Markdown
Contributor

While adding implementation status for nl_types.h, I noticed docgen resolves it to nl-types.h instead of nl_types.h. As a result, headers with underscores are not matched correctly and their implementation status is not marked.

This patch fixes the handling of underscored header names in docgen so they are processed consistently.

@llvmbot llvmbot added the libc label Apr 27, 2026
@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Apr 27, 2026

@llvm/pr-subscribers-libc

Author: Petter Berntsson (petbernt)

Changes

While adding implementation status for nl_types.h, I noticed docgen resolves it to nl-types.h instead of nl_types.h. As a result, headers with underscores are not matched correctly and their implementation status is not marked.

This patch fixes the handling of underscored header names in docgen so they are processed consistently.


Full diff: https://github.com/llvm/llvm-project/pull/194367.diff

1 Files Affected:

  • (modified) libc/utils/docgen/header.py (+3-1)
diff --git a/libc/utils/docgen/header.py b/libc/utils/docgen/header.py
index 8885db42f0a5b..d43831eb48af8 100644
--- a/libc/utils/docgen/header.py
+++ b/libc/utils/docgen/header.py
@@ -112,5 +112,7 @@ def __get_macro_files(self) -> Generator[Path, None, None]:
         instead use a hyphen in the name.
         libc/include/llvm-libc-macros/sys-mman-macros.h
         """
-        stem = self.stem.replace("/", "-")
+        # Some POSIX headers use underscores in the header name but hyphens in
+        # the macro file name, e.g. nl_types.h -> nl-types-macros.h.
+        stem = self.stem.replace("/", "-").replace("_", "-")
         return self.macros_dir.glob(f"**/{stem}-macros.h")

@petbernt
Copy link
Copy Markdown
Contributor Author

@kaladron

Comment thread libc/utils/docgen/header.py Outdated
stem = self.stem.replace("/", "-")
# Some POSIX headers use underscores in the header name but hyphens in
# the macro file name, e.g. nl_types.h -> nl-types-macros.h.
stem = self.stem.replace("/", "-").replace("_", "-")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe unrelated to the change, but wouldn't it be better if we renamed nl-types-macros.h to nl_types-macros.h?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think either approach works, but renaming nl-types-macros.h to nl_types-macros.h is probably the cleaner fix since it removes the naming inconsistency at the source.

This patch was only meant to make the implementation-status lookup match the current repository state.

I’m happy to switch to the rename instead!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelrj-google Do you have a preference here? I'm inclined to say that the filenames are probably wrong and should be fixed, but I want to make sure you don't have something in mind here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and switched this to the rename-based fix since that seemed like the cleaner direction.

Happy to adjust if there’s a preference for the original docgen-based approach.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general I prefer the simplest solution. As a short term fix I think the PR only renaming nl_types is the best solution, then a followup PR to move all the relevant POSIX headers along with the docgen change would make sense.

@petbernt petbernt force-pushed the libc-docs-fix-docgen-underscored-headers branch from a1e12c0 to e33f7d0 Compare April 27, 2026 14:49
Copy link
Copy Markdown
Member

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as-is

@petbernt petbernt requested a review from kaladron April 29, 2026 12:35
@petbernt
Copy link
Copy Markdown
Contributor Author

Feel free to merge it for me as well, as I do not have merge permissions.

kaladron pushed a commit that referenced this pull request Apr 30, 2026
…4373)

Add nl_types.h implementation-status docs to llvm-libc.

Depends on PR #194367. That change fixes docgen lookup for underscored
headers, without it, the macros of nl_types.h implementation status is
not reported accurately.
@michaelrj-google michaelrj-google merged commit ca9f6c5 into llvm:main Apr 30, 2026
32 checks passed
@petbernt petbernt deleted the libc-docs-fix-docgen-underscored-headers branch April 30, 2026 18:59
enferex pushed a commit to enferex/llvm-project that referenced this pull request May 5, 2026
…lvm#194373)

Add nl_types.h implementation-status docs to llvm-libc.

Depends on PR llvm#194367. That change fixes docgen lookup for underscored
headers, without it, the macros of nl_types.h implementation status is
not reported accurately.
enferex pushed a commit to enferex/llvm-project that referenced this pull request May 5, 2026
…4367)

While adding implementation status for nl_types.h, I noticed docgen
resolves it to nl-types.h instead of nl_types.h. As a result, headers
with underscores are not matched correctly and their implementation
status is not marked.

This patch fixes the handling of underscored header names in docgen so
they are processed consistently.
moar55 pushed a commit to moar55/llvm-project that referenced this pull request May 12, 2026
…lvm#194373)

Add nl_types.h implementation-status docs to llvm-libc.

Depends on PR llvm#194367. That change fixes docgen lookup for underscored
headers, without it, the macros of nl_types.h implementation status is
not reported accurately.
moar55 pushed a commit to moar55/llvm-project that referenced this pull request May 12, 2026
…4367)

While adding implementation status for nl_types.h, I noticed docgen
resolves it to nl-types.h instead of nl_types.h. As a result, headers
with underscores are not matched correctly and their implementation
status is not marked.

This patch fixes the handling of underscored header names in docgen so
they are processed consistently.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants