fix(tool): preserve Python header documentation - #928
Conversation
Co-authored-by: xushiwei <396972+xushiwei@users.noreply.github.com>
Co-authored-by: xushiwei <396972+xushiwei@users.noreply.github.com>
Co-authored-by: xushiwei <396972+xushiwei@users.noreply.github.com>
|
@copilot The |
There was a problem hiding this comment.
Review: fix(tool): preserve Python header documentation
The change is small, well-scoped, and backward compatible. Adding an opt-in KeepDoc config that threads -fparse-all-comments into clang is the right mechanism for surfacing ordinary C header comments, and refactoring ParseSources into a public wrapper + private parseSources(..., keepDoc) preserves the existing exported signature — good call. The fixture llcppg.cfg plus regenerated goldens give regression coverage.
One substantive question and a couple of doc nits below. No blocking issues.
Design note worth confirming (not necessarily a bug): cfg.KeepDoc is threaded only into the clang parse flag; NewPackage never sets cl.Config.DontKeepDoc, so cl's internal keepDoc is always true in the tool path (comment emission is always on). In contrast, the test harness ties the two together via DontKeepDoc: !conf.KeepDoc (cl/compile_test.go:111). So in the tool path, KeepDoc=false still emits Doxygen-style doc comments and only suppresses ordinary comment parsing — which may well be intended, but the asymmetry with the cltest path is easy to trip over. See the inline note on tool/gen.go.
Co-authored-by: xushiwei <396972+xushiwei@users.noreply.github.com>
Removed |
TestPythongenerated bindings without comments from declarations in Python headers. Clang requires-fparse-all-commentsto expose these ordinary C comments.KeepDocsupport to tool configuration; when enabled, parse headers with-fparse-all-comments.KeepDocand update generated goldens with the extracted comments.{ "KeepDoc": true }