Conversation
cxxheaderparser discards comments, so the generated C API carried no documentation even though the C++ headers document most public functions. Add a small extractor that recovers /** */ blocks from the raw header text and matches each to its declaration by qualified name and parameter arity (exact arity only — no lenient fallback, which would steal a sibling overload's doc), then emit the block above each declaration in generated headers. Implementation files are unchanged; this is additive documentation for downstream FFI consumers.
MLX's C++ headers document some functions with @code blocks written in C++ (auto, std::vector, ->). Carried verbatim into C bindings these are meaningless to C consumers. Add a conservative sanitizer in docextract.py: @code fences containing C++-only tokens are dropped and replaced by a single 'Code example omitted: written in C++.' note; consecutive omissions merge into one note; dangling lead-in sentences ending in ':' above an omitted block are removed; blank runs collapse. Blocks without C++ tokens pass through verbatim. Nothing is silently rewritten — every application of a rule is recorded.
Regenerating a header without passing --docstring silently dropped its defgroup banner. When the flag is missing, reuse the title from the previously generated mlx/c/<header>.h if one exists, so regeneration reproduces the committed form.
MLX's C++ headers open with a structural \defgroup comment directly
above the first declaration. Treating it as that declaration's doc
re-emitted a duplicate group banner mid-header. Structural commands
(\defgroup/\addtogroup/\ingroup/@{/@}) are now ignored by the
extractor; c.py already emits the file-level group from --docstring.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cxxheaderparser discards comments, so the generated C API carried no documentation even though the C++ headers document most public functions. Add a small extractor that recovers /** */ blocks from the raw header text and matches each to its declaration by qualified name and parameter arity (exact arity only — no lenient fallback, which would steal a sibling overload's doc), then emit the block above each declaration in generated headers.
This includes a basic sanitizer to prevent c++-isms from being emitted in comments.