Skip to content

Instantly share code, notes, and snippets.

@regularberry
Created June 29, 2018 13:55
Show Gist options
  • Save regularberry/ee1ed860a3b82e2eff107c72158ca7c7 to your computer and use it in GitHub Desktop.
Save regularberry/ee1ed860a3b82e2eff107c72158ca7c7 to your computer and use it in GitHub Desktop.
let structBuilder = StructSpec.builder(for: "TestStruct")
let fieldBuilder = FieldSpec.builder(for: "myField", type: .StringType, construct: nil)
structBuilder.add(field: fieldBuilder.build())
let poet = PoetFile(list: [structBuilder.build()], generatorInfo: nil)
print(poet.fileContents)
/// OUTPUT
-----------
//
// TestStruct.swift
//
// Contains:
// struct TestStruct
//
// Generated by SwiftPoet on 6/29/18
//
struct TestStruct {
let myField: String
/**
:param: myField
*/
internal init(myField: String) {
self.myField = myField
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment