feat: implement rustdoc comment generation support #190
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.
Description
This PR brings the Rust generator closer to feature parity by adding support for documentation comments. It implements a
writeDescriptionhelper method that converts Concerto model descriptions into standard Rust documentation comments (///).Changes
writeDescriptionhelper method toRustVisitorclass.visitClassDeclarationto generate documentation for Structs and Enums.visitFieldto generate documentation for Fields (including HashMap support).visitRelationshipDeclarationto generate documentation for Relationships.Testing & Verification
I verified this logic locally using a debug script.
Note on Upstream Parser Behavior:
I discovered that the current version of
@accordproject/concerto-cto(v3.25.0) used in this repository appears to strip comments during AST parsing. As a result,thing.getDescription()returnsundefinedby default when parsing a string.To verify that my
RustVisitorlogic works correctly, I used a script that manually injects descriptions into theClassDeclarationobjects in memory after parsing. This confirmed that the generator correctly formats and outputs the RustDoc comments when the data is present in the model.Verification Script (
debug-rust.js)here is the debug script output which I got, after the modifications I made to rustvisitor.js:

Line 7 shows that the comment has been injected.
I am uploading the two files,
debug-rust.jshere:debug-rust.js