Skip to content
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

feat(comment): add comment flag #90

Closed
wants to merge 2 commits into from
Closed

Conversation

peam1146
Copy link

@peam1146 peam1146 commented Oct 3, 2023

What I did.

This pull request introduces a new feature to the Goverter library: the -commentOnStruct flag. This feature allows users to add comments above generated structs, which can be especially useful when working with other code generation tools like Autowire.

Changes Made

I have introduced a new command-line flag, -commentOnStruct, which, when enabled, will add a comment above each generated struct. These comments can provide valuable information about the struct's purpose, source, or usage.

Example Usage

goverter -commentOnStruct "// @autowire(set=converter)" <otherFlag> <path>

result

// @autowire(set=converter)
type ConverterImpl struct{}

peam1146 and others added 2 commits October 3, 2023 19:44
@@ -14,6 +14,7 @@ func main() {
output := flag.String("output", "./generated/generated.go", "")
extends := flag.String("extends", "", "comma separated list of local or package extends")
packagePath := flag.String("packagePath", "", "optional full package path for the generated code")
commentOnStruct := flag.String("commentOnStruct", "", "optional comment on the generated struct")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rather not have this as a cli flag, it should be a comment that can be added to the converter interface. Something like goverter:structComment and it should be possible to apply this multiple times like

// goverter:converter
// goverter:structComment MyConverterImpl
// goverter:structComment
// goverter:structComment More detailed description
// goverter:structComment @autowire(set=converter)
type Converter interface {
	Convert(source []Input) []Output
}

Furthermore this feature requires some tests scenarios defined in the scenario directory and docs in docs/conversion/misc.md

@jmattheis jmattheis mentioned this pull request Nov 3, 2023
@jmattheis jmattheis closed this in #94 Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants