-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Use Stencil Templating engine to create service files #153
Conversation
Currently disabled
This is so I can compare with newly generated files which are built from template files and seem to require a new line at the end
Updated stencils to get them to be as accurate to original output
One difference in ElasticBeanstalk_Shapes.swift where the parameters p99 and p999 are ordered differently
- Changed AUTOMATICALLY GENERATED message to point to swft-aws - Removed newline near end of api files - Tidied up template files to make them easier to read - Sort variables by their lowercase version
I made an addition to Stencil which removes newlines immediately after blocks. Using this I could then clean up the stencil templates to make them a lot easier to read. Unfortunately development on Stencil seems to have gone quiet so forked the repository and made the change locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor questions; this is amazing!
To make sure I'm understanding, we now split this into two phases. The first builds up the context
s, then we drop those into the stencil templates.
This looks so great! Thanks for leading the charge here!!
CodeGenerator/Package.swift
Outdated
.package(url: "https://github.com/swift-aws/aws-sdk-swift-core.git", .branch("master")), | ||
.package(url: "https://github.com/IBM-Swift/SwiftyJSON.git", .upToNextMajor(from: "17.0.2")) | ||
.package(url: "https://github.com/IBM-Swift/SwiftyJSON.git", .upToNextMajor(from: "17.0.2")), | ||
.package(url: "https://github.com/adam-fowler/Stencil.git", .upToNextMajor(from: "0.13.4")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And to confirm, the plan is to move back to upstream once this is merged, yah? (thanks for finding + fixing!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one other more important change, that implements the clearing of whitespace based on changes from another pull request. I struggled to merge that into the head so re-implemented it. It is more important that that PR is merged into the head of Stencil. For now when this goes into aws-sdk-swift I was going to create a fork Stencil with my changes into swift-aws so the code is centralised.
@@ -7,10 +7,10 @@ let package = Package( | |||
.executable(name: "aws-sdk-swift-codegen", targets: ["CodeGenerator"]) | |||
], | |||
dependencies: [ | |||
.package(url: "https://github.com/swift-aws/aws-sdk-swift-core.git", .branch("master")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So awesome 👏
@@ -254,6 +258,7 @@ struct AWSService { | |||
var shapes = [Shape]() | |||
for (key, json) in apiJSON["shapes"].dictionaryValue { | |||
do { | |||
//if json["deprecated"].bool == true { continue } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep ok
case .string(_): | ||
return "String" | ||
case .integer(_): | ||
return "Int32" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just use Int
if possible, yah?
Unless you need to work with a specific size of integer, always use Int for integer values in your code.
— Section onInt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah gonna do that in a later change
return "let \(name.toSwiftVariableCase()): \(swiftTypeName)\(optionalSuffix)" | ||
|
||
struct OperationContext { | ||
let comment : [String.SubSequence] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A minor nit, how come the space before the :
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's something I've always done. Can change if required
So yes you are correct. We build up the contexts and then these are 'rendered' using the stencil templates. The dictionary keys / structure member names, correspond to the names used in the templates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
If partition endpoint is set ensure all regions setup their endpoint correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brilliant!
Uses https://github.com/stencilproject/Stencil to create service files.
I added a few minor features while doing this