Closed justinfx closed 3 years ago
@sbinet in hindsight I should have used struct tags. It makes more sense and probably would have saved me the trouble of trying to locate the comments for the field. I was only thinking of making them the same as the other types, but a struct tag is better suited for settings like this that would be removed from the doc string. Let me work up another commit to try and change this.
Yeah I agree that on balance the field tag makes more sense. All kinds of impl stuff is leaked through those so I don't think this is any different, and is idiomatic in my experience.
I've now added struct tag parsing of gopy:"new_name"
. Please let me know if you want me to remove the doc comment parsing logic entirely, or leave it in? I left it just for consistency with the other types, but the tag wins.
the Go style is to have only one way to do things where possible, so probably remove it..
I've removed the property getter/setter doc parsing for a name override. But I have left the struct field getDoc
updates because they are needed to pull the comments to then set the property docstring in python
Yep looks good to me too -- thanks for the contributions!
This merge improves the support for controlling the generates names of functions, methods, and properties in the python code. The "gopy:name" tag support has been extended to struct fields and updated to also support single line comments:
A new optional feature flat
-rename
has been added to apply automatic PEP8 snake_case name transformations to functions, methods, properties, and var getter/setters. This makes it more convenient than having to annotate every symbol in Go source with agopy:name
tag if we only want CamelCase converted to snake_case to be more "pythonic".And lastly, as part of parsing the comments for struct fields, the docstring is actually also applied to the python property getter in the generated code.
Objectives:
rename
flag and auto naming feature useful and complete enough?