-
Notifications
You must be signed in to change notification settings - Fork 36
feat: implement rustdoc comment generation support #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -304,6 +304,7 @@ class RustVisitor { | |||||||||
| * @private | ||||||||||
| */ | ||||||||||
| visitClassDeclaration(classDeclaration, parameters) { | ||||||||||
| this.writeDescription(classDeclaration, parameters, 0); | ||||||||||
| parameters.fileWriter.writeLine( | ||||||||||
| 0, | ||||||||||
| '#[derive(Debug, Clone, Serialize, Deserialize)]' | ||||||||||
|
|
@@ -513,6 +514,8 @@ class RustVisitor { | |||||||||
| if (field.isOptional?.()) { | ||||||||||
| hashMapType = this.wrapAsOption(hashMapType); | ||||||||||
| } | ||||||||||
| // Add description for HashMap fields | ||||||||||
| this.writeDescription(field, parameters, 1); | ||||||||||
|
|
||||||||||
| // Generate serde attributes for HashMap with DateTime serialization support | ||||||||||
| parameters.fileWriter.writeLine(1, '#[serde('); | ||||||||||
|
|
@@ -607,6 +610,10 @@ class RustVisitor { | |||||||||
| } | ||||||||||
|
|
||||||||||
| // Handle regular (non-HashMap) fields | ||||||||||
|
|
||||||||||
| // Add description for regular fields | ||||||||||
| this.writeDescription(field, parameters, 1); | ||||||||||
|
|
||||||||||
| parameters.fileWriter.writeLine(1, '#[serde('); | ||||||||||
| parameters.fileWriter.writeLine(2, `rename = "${field.name}",`); | ||||||||||
| if (field.isOptional?.()) { | ||||||||||
|
|
@@ -752,6 +759,7 @@ class RustVisitor { | |||||||||
| if (relationshipDeclaration.isOptional?.()) { | ||||||||||
| type = `Option<${type}>`; | ||||||||||
| } | ||||||||||
| this.writeDescription(relationshipDeclaration, parameters, 1); | ||||||||||
|
|
||||||||||
| // Start serde attribute block | ||||||||||
| parameters.fileWriter.writeLine(1, '#[serde('); | ||||||||||
|
|
@@ -1327,6 +1335,31 @@ class RustVisitor { | |||||||||
|
|
||||||||||
| parameters.fileWriter.closeFile(); | ||||||||||
| } | ||||||||||
| /** | ||||||||||
| * Writes the description of a declaration or property as a Rust documentation comment. | ||||||||||
| * @param {Object} thing - the declaration or property | ||||||||||
| * @param {Object} parameters - the parameters | ||||||||||
| * @param {number} indent - the indentation level | ||||||||||
| * @private | ||||||||||
| */ | ||||||||||
| writeDescription(thing, parameters, indent) { | ||||||||||
| if (thing.getDescription && thing.getDescription()) { | ||||||||||
| const description = thing.getDescription(); | ||||||||||
|
Comment on lines
+1346
to
+1347
|
||||||||||
| if (thing.getDescription && thing.getDescription()) { | |
| const description = thing.getDescription(); | |
| const description = thing.getDescription && thing.getDescription(); | |
| if (typeof description === 'string' && description.length > 0) { |
Uh oh!
There was an error while loading. Please reload this page.