Commit 950b63a
Add protobuf source comment support to generated Rust code (#7)
## Summary
- Extract comments from protobuf `SourceCodeInfo` and emit them as Rust
doc comments (`///`) on generated structs, fields, enums, enum variants,
oneof enums, and view types
- Add `comments.rs` module that translates index-based `SourceCodeInfo`
paths into an FQN-keyed `HashMap` on `CodeGenContext`, so codegen call
sites look up comments by the proto FQN they already have
- Add `--include_source_info` to all `protoc` invocations
(`buffa-build`, WKT generation, bootstrap generation)
- Combine proto source comments with existing tag docs (e.g. `Field 1:
\`seconds\``) using a blank-line separator
- Regenerate all checked-in generated code (WKTs + bootstrap descriptor
types) with full proto documentation
## Test plan
- [x] All 1,244 existing tests pass
- [x] Clippy clean (zero warnings)
- [x] 17 new tests: 11 unit tests in `comments.rs` (edge cases: empty
SCI, nested types, whitespace-only, detached comments, empty package) +
6 integration tests in `tests/comments.rs` (end-to-end through
`generate()`)
- [x] Verified generated WKT types have full proto documentation (e.g.
`Timestamp` struct has 50+ line doc comment from proto source)
- [x] Verified bootstrap descriptor types have proto comments on fields
- [x] CI: lint-and-test, check-generated-code, conformance suite
---------
Co-authored-by: Iain McGinniss <309153+iainmcgin@users.noreply.github.com>1 parent a03474c commit 950b63a
File tree
24 files changed
+3214
-13
lines changed- .github/workflows
- buffa-build/src
- buffa-codegen/src
- generated
- tests
- buffa-types/src/generated
- examples/logging/src/gen
- scripts
24 files changed
+3214
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
131 | 132 | | |
132 | 133 | | |
133 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
| 436 | + | |
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
519 | 519 | | |
520 | 520 | | |
521 | 521 | | |
| 522 | + | |
522 | 523 | | |
523 | 524 | | |
524 | 525 | | |
| |||
555 | 556 | | |
556 | 557 | | |
557 | 558 | | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
558 | 562 | | |
559 | 563 | | |
560 | 564 | | |
| |||
0 commit comments