From 5fc04f903f7ec095e62e69aa2a142e1a76def201 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Thu, 11 May 2017 21:49:13 +0200 Subject: [PATCH 01/12] rename `default` templates to `swift2` & remove some old templates --- templates/colors/rawValue.stencil | 49 ------- .../{default.stencil => swift2.stencil} | 0 .../fonts/{default.stencil => swift2.stencil} | 0 templates/images/allvalues.stencil | 77 ----------- templates/images/default.stencil | 61 --------- templates/images/dot-syntax-swift3.stencil | 84 ------------ .../{dot-syntax.stencil => swift2.stencil} | 0 templates/images/swift3.stencil | 71 ++++++---- templates/storyboards/lowercase.stencil | 121 ------------------ ...x-default.stencil => macOS-swift2.stencil} | 0 ...sx-swift3.stencil => macOS-swift3.stencil} | 0 templates/storyboards/osx-lowercase.stencil | 102 --------------- .../{default.stencil => swift2.stencil} | 0 templates/storyboards/uppercase.stencil | 121 ------------------ ...ntax.stencil => dot-syntax-swift2.stencil} | 0 .../{default.stencil => flat-swift2.stencil} | 0 .../{swift3.stencil => flat-swift3.stencil} | 0 templates/strings/genstrings.stencil | 63 --------- templates/strings/no-comments-swift3.stencil | 61 --------- templates/strings/structured.stencil | 74 ----------- 20 files changed, 47 insertions(+), 837 deletions(-) delete mode 100644 templates/colors/rawValue.stencil rename templates/colors/{default.stencil => swift2.stencil} (100%) rename templates/fonts/{default.stencil => swift2.stencil} (100%) delete mode 100644 templates/images/allvalues.stencil delete mode 100644 templates/images/default.stencil delete mode 100644 templates/images/dot-syntax-swift3.stencil rename templates/images/{dot-syntax.stencil => swift2.stencil} (100%) delete mode 100644 templates/storyboards/lowercase.stencil rename templates/storyboards/{osx-default.stencil => macOS-swift2.stencil} (100%) rename templates/storyboards/{osx-swift3.stencil => macOS-swift3.stencil} (100%) delete mode 100644 templates/storyboards/osx-lowercase.stencil rename templates/storyboards/{default.stencil => swift2.stencil} (100%) delete mode 100644 templates/storyboards/uppercase.stencil rename templates/strings/{dot-syntax.stencil => dot-syntax-swift2.stencil} (100%) rename templates/strings/{default.stencil => flat-swift2.stencil} (100%) rename templates/strings/{swift3.stencil => flat-swift3.stencil} (100%) delete mode 100644 templates/strings/genstrings.stencil delete mode 100644 templates/strings/no-comments-swift3.stencil delete mode 100644 templates/strings/structured.stencil diff --git a/templates/colors/rawValue.stencil b/templates/colors/rawValue.stencil deleted file mode 100644 index 3ee9595..0000000 --- a/templates/colors/rawValue.stencil +++ /dev/null @@ -1,49 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -{% if colors %} -#if os(OSX) - import AppKit.NSColor - typealias Color = NSColor -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIColor - typealias Color = UIColor -#endif - -// swiftlint:disable file_length - -// swiftlint:disable operator_usage_whitespace -extension Color { - convenience init(rgbaValue: UInt32) { - let red = CGFloat((rgbaValue >> 24) & 0xff) / 255.0 - let green = CGFloat((rgbaValue >> 16) & 0xff) / 255.0 - let blue = CGFloat((rgbaValue >> 8) & 0xff) / 255.0 - let alpha = CGFloat((rgbaValue ) & 0xff) / 255.0 - - self.init(red: red, green: green, blue: blue, alpha: alpha) - } -} -// swiftlint:enable operator_usage_whitespace - -// swiftlint:disable identifier_name line_length type_body_length -{% set enumName %}{{param.enumName|default:"ColorName"|swiftIdentifier}}{% endset %} -enum {{enumName}}: UInt32 { - {% for color in colors %} - /// - /// Alpha: {{color.alpha|hexToInt|int255toFloat|percent}}
(0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}}) - case {{color.name|swiftIdentifier|escapeReservedKeywords}} = 0x{{color.red}}{{color.green}}{{color.blue}}{{color.alpha}} - {% endfor %} - - var color: Color { - return Color(named: self) - } -} -// swiftlint:enable identifier_name line_length type_body_length - -extension Color { - convenience init(named name: {{enumName}}) { - self.init(rgbaValue: name.rawValue) - } -} -{% else %} -// No color found -{% endif %} diff --git a/templates/colors/default.stencil b/templates/colors/swift2.stencil similarity index 100% rename from templates/colors/default.stencil rename to templates/colors/swift2.stencil diff --git a/templates/fonts/default.stencil b/templates/fonts/swift2.stencil similarity index 100% rename from templates/fonts/default.stencil rename to templates/fonts/swift2.stencil diff --git a/templates/images/allvalues.stencil b/templates/images/allvalues.stencil deleted file mode 100644 index 6ce94f6..0000000 --- a/templates/images/allvalues.stencil +++ /dev/null @@ -1,77 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -{% if catalogs %} -#if os(OSX) - import AppKit.NSImage - typealias Image = NSImage -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIImage - typealias Image = UIImage -#endif - -// swiftlint:disable file_length -{% macro recursiveCaseBlock images %} - {% for image in images %} - {% if not image.items %} - case {{image.value|swiftIdentifier|escapeReservedKeywords}} = "{{image.value}}" - {% else %} - {% call recursiveCaseBlock image.items %} - {% endif %} - {% endfor %} -{% endmacro %} -{% macro recursiveValueBlock images isLast %} - {% for image in images %} - {% if not image.items %} - {{image.value|swiftIdentifier|escapeReservedKeywords}}{% if not forloop.last or not isLast %},{% endif %} - {% else %} - {% call recursiveValueBlock image.items forloop.last %} - {% endif %} - {% endfor %} -{% endmacro %} - -// swiftlint:disable identifier_name line_length type_body_length -{% set enumName %}{{param.enumName|default:"Asset"}}{% endset %} -enum {{enumName}}: String { - {% for catalog in catalogs %} - {% call recursiveCaseBlock catalog.assets %} - {% endfor %} - - // swiftlint:disable:next explicit_type_interface - static let allValues = [ - {% for catalog in catalogs %} - {% call recursiveValueBlock catalog.assets false %} - {% endfor %} - ] -} -// swiftlint:enable identifier_name line_length type_body_length - -extension {{enumName}} { - var image: Image { - let bundle = NSBundle(forClass: BundleToken.self) - #if os(iOS) || os(tvOS) - let image = Image(named: rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) - let image = bundle.imageForResource(rawValue) - #elseif os(watchOS) - let image = Image(named: rawValue) - #endif - guard let result = image else { fatalError("Unable to load image \(rawValue).") } - return result - } -} - -extension Image { - convenience init!(asset: {{enumName}}) { - #if os(iOS) || os(tvOS) - let bundle = NSBundle(forClass: BundleToken.self) - self.init(named: asset.rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) || os(watchOS) - self.init(named: asset.rawValue) - #endif - } -} - -private final class BundleToken {} -{% else %} -// No image found -{% endif %} diff --git a/templates/images/default.stencil b/templates/images/default.stencil deleted file mode 100644 index 41d31be..0000000 --- a/templates/images/default.stencil +++ /dev/null @@ -1,61 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -{% if catalogs %} -#if os(OSX) - import AppKit.NSImage - typealias Image = NSImage -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIImage - typealias Image = UIImage -#endif - -// swiftlint:disable file_length -{% macro recursiveBlock images %} - {% for image in images %} - {% if not image.items %} - case {{image.value|swiftIdentifier|escapeReservedKeywords}} = "{{image.value}}" - {% else %} - {% call recursiveBlock image.items %} - {% endif %} - {% endfor %} -{% endmacro %} - -// swiftlint:disable identifier_name line_length type_body_length -{% set enumName %}{{param.enumName|default:"Asset"}}{% endset %} -enum {{enumName}}: String { - {% for catalog in catalogs %} - {% call recursiveBlock catalog.assets %} - {% endfor %} -} -// swiftlint:enable identifier_name line_length type_body_length - -extension {{enumName}} { - var image: Image { - let bundle = NSBundle(forClass: BundleToken.self) - #if os(iOS) || os(tvOS) - let image = Image(named: rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) - let image = bundle.imageForResource(rawValue) - #elseif os(watchOS) - let image = Image(named: rawValue) - #endif - guard let result = image else { fatalError("Unable to load image \(rawValue).") } - return result - } -} - -extension Image { - convenience init!(asset: {{enumName}}) { - #if os(iOS) || os(tvOS) - let bundle = NSBundle(forClass: BundleToken.self) - self.init(named: asset.rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) || os(watchOS) - self.init(named: asset.rawValue) - #endif - } -} - -private final class BundleToken {} -{% else %} -// No image found -{% endif %} diff --git a/templates/images/dot-syntax-swift3.stencil b/templates/images/dot-syntax-swift3.stencil deleted file mode 100644 index c96ac37..0000000 --- a/templates/images/dot-syntax-swift3.stencil +++ /dev/null @@ -1,84 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -{% if catalogs %} -#if os(OSX) - import AppKit.NSImage - typealias Image = NSImage -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIImage - typealias Image = UIImage -#endif - -// swiftlint:disable file_length - -{% set enumName %}{{param.enumName|default:"Asset"}}{% endset %} -struct {{enumName}}Type: ExpressibleByStringLiteral { - fileprivate var value: String - - var image: Image { - let bundle = Bundle(for: BundleToken.self) - #if os(iOS) || os(tvOS) - let image = Image(named: value, in: bundle, compatibleWith: nil) - #elseif os(OSX) - let image = bundle.image(forResource: value) - #elseif os(watchOS) - let image = Image(named: value) - #endif - guard let result = image else { fatalError("Unable to load image \(value).") } - return result - } - - init(stringLiteral value: String) { - self.value = value - } - - init(extendedGraphemeClusterLiteral value: String) { - self.init(stringLiteral: value) - } - - init(unicodeScalarLiteral value: String) { - self.init(stringLiteral: value) - } -} -{% macro recursiveBlock images sp %} -{{sp}} {% for image in images %} -{{sp}} {% if not image.items %} -{{sp}} static let {{image.name|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}}: {{enumName}}Type = "{{image.value}}" -{{sp}} {% else %} -{{sp}} enum {{image.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}} { -{{sp}} {% set sp2 %}{{sp}} {% endset %} -{{sp}} {% call recursiveBlock image.items sp2 %} -{{sp}} } -{{sp}} {% endif %} -{{sp}} {% endfor %} -{% endmacro %} - -// swiftlint:disable identifier_name line_length nesting type_body_length type_name -enum {{enumName}} { - {% if catalogs.count > 1 %} - {% for catalog in catalogs %} - enum {{catalog.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}} { - {% call recursiveBlock catalog.assets " " %} - } - {% endfor %} - {% else %} - {% call recursiveBlock catalogs.first.assets "" %} - {% endif %} -} -// swiftlint:enable identifier_name line_length nesting type_body_length type_name - -extension Image { - convenience init!(asset: {{enumName}}Type) { - #if os(iOS) || os(tvOS) - let bundle = Bundle(for: BundleToken.self) - self.init(named: asset.value, in: bundle, compatibleWith: nil) - #elseif os(OSX) || os(watchOS) - self.init(named: asset.value) - #endif - } -} - -private final class BundleToken {} -{% else %} -// No image found -{% endif %} diff --git a/templates/images/dot-syntax.stencil b/templates/images/swift2.stencil similarity index 100% rename from templates/images/dot-syntax.stencil rename to templates/images/swift2.stencil diff --git a/templates/images/swift3.stencil b/templates/images/swift3.stencil index b35243e..c96ac37 100644 --- a/templates/images/swift3.stencil +++ b/templates/images/swift3.stencil @@ -10,47 +10,70 @@ #endif // swiftlint:disable file_length -{% macro recursiveBlock images %} - {% for image in images %} - {% if not image.items %} - case {{image.value|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}} = "{{image.value}}" - {% else %} - {% call recursiveBlock image.items %} - {% endif %} - {% endfor %} -{% endmacro %} -// swiftlint:disable identifier_name line_length type_body_length {% set enumName %}{{param.enumName|default:"Asset"}}{% endset %} -enum {{enumName}}: String { - {% for catalog in catalogs %} - {% call recursiveBlock catalog.assets %} - {% endfor %} -} -// swiftlint:enable identifier_name line_length type_body_length +struct {{enumName}}Type: ExpressibleByStringLiteral { + fileprivate var value: String -extension {{enumName}} { var image: Image { let bundle = Bundle(for: BundleToken.self) #if os(iOS) || os(tvOS) - let image = Image(named: rawValue, in: bundle, compatibleWith: nil) + let image = Image(named: value, in: bundle, compatibleWith: nil) #elseif os(OSX) - let image = bundle.image(forResource: rawValue) + let image = bundle.image(forResource: value) #elseif os(watchOS) - let image = Image(named: rawValue) + let image = Image(named: value) #endif - guard let result = image else { fatalError("Unable to load image \(rawValue).") } + guard let result = image else { fatalError("Unable to load image \(value).") } return result } + + init(stringLiteral value: String) { + self.value = value + } + + init(extendedGraphemeClusterLiteral value: String) { + self.init(stringLiteral: value) + } + + init(unicodeScalarLiteral value: String) { + self.init(stringLiteral: value) + } +} +{% macro recursiveBlock images sp %} +{{sp}} {% for image in images %} +{{sp}} {% if not image.items %} +{{sp}} static let {{image.name|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}}: {{enumName}}Type = "{{image.value}}" +{{sp}} {% else %} +{{sp}} enum {{image.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}} { +{{sp}} {% set sp2 %}{{sp}} {% endset %} +{{sp}} {% call recursiveBlock image.items sp2 %} +{{sp}} } +{{sp}} {% endif %} +{{sp}} {% endfor %} +{% endmacro %} + +// swiftlint:disable identifier_name line_length nesting type_body_length type_name +enum {{enumName}} { + {% if catalogs.count > 1 %} + {% for catalog in catalogs %} + enum {{catalog.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}} { + {% call recursiveBlock catalog.assets " " %} + } + {% endfor %} + {% else %} + {% call recursiveBlock catalogs.first.assets "" %} + {% endif %} } +// swiftlint:enable identifier_name line_length nesting type_body_length type_name extension Image { - convenience init!(asset: {{enumName}}) { + convenience init!(asset: {{enumName}}Type) { #if os(iOS) || os(tvOS) let bundle = Bundle(for: BundleToken.self) - self.init(named: asset.rawValue, in: bundle, compatibleWith: nil) + self.init(named: asset.value, in: bundle, compatibleWith: nil) #elseif os(OSX) || os(watchOS) - self.init(named: asset.rawValue) + self.init(named: asset.value) #endif } } diff --git a/templates/storyboards/lowercase.stencil b/templates/storyboards/lowercase.stencil deleted file mode 100644 index 9b28b14..0000000 --- a/templates/storyboards/lowercase.stencil +++ /dev/null @@ -1,121 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -{% if storyboards %} -// swiftlint:disable sorted_imports -{% macro className scene %}{% if scene.customClass %}{% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}{% else %}UI{{scene.baseType}}{% endif %}{% endmacro %} -import Foundation -import UIKit -{% for module in modules where module != env.PRODUCT_MODULE_NAME and module != param.module %} -import {{module}} -{% endfor %} - -// swiftlint:disable file_length - -{# This first part of the code is static, same every time whatever Storyboard you have #} -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> UIStoryboard { - return UIStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialViewController() -> UIViewController { - guard let vc = storyboard().instantiateInitialViewController() else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func viewController() -> UIViewController { - return Self.storyboard().instantiateViewControllerWithIdentifier(self.rawValue) - } - static func viewController(identifier: Self) -> UIViewController { - return identifier.viewController() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension UIViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -{# This is where the generation begins, this code depends on what you have in your Storyboards #} -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -{% set sceneEnumName %}{{param.sceneEnumName|default:"StoryboardScene"}}{% endset %} -enum {{sceneEnumName}} { - {% for storyboard in storyboards %} - {% set storyboardName %}{{storyboard.name|swiftIdentifier|escapeReservedKeywords}}{% endset %} - {% if storyboard.scenes %} - enum {{storyboardName}}: String, StoryboardSceneType { - static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene and storyboard.initialScene.baseType != "ViewController" %} - {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} - - static func initialViewController() -> {{initialSceneClass}} { - guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - {% endif %} - {% for scene in storyboard.scenes %} - {% set sceneID %}{{scene.identifier|swiftIdentifier|lowerFirstWord}}{% endset %} - - case {{sceneID|escapeReservedKeywords}}{% if sceneID != scene.identifier %} = "{{scene.identifier}}"{% endif %} - {% if scene.baseType != "ViewController" %} - {% set sceneClass %}{% call className scene %}{% endset %} - static func {{sceneID}}ViewController() -> {{sceneClass}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID|escapeReservedKeywords}}.viewController() as? {{sceneClass}} - else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class {{sceneClass}}.") - } - return vc - } - {% else %} - static func {{sceneID|lowerFirstWord}}ViewController() -> UIViewController { - return {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}.viewController() - } - {% endif %} - {% endfor %} - } - {% else %} - enum {{storyboardName}}: StoryboardSceneType { - static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene and storyboard.initialScene.baseType != "ViewController" %} - {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} - - static func initialViewController() -> {{initialSceneClass}} { - guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - {% endif %} - } - {% endif %} - {% endfor %} -} - -enum {{param.segueEnumName|default:"StoryboardSegue"}} { - {% for storyboard in storyboards where storyboard.segues %} - enum {{storyboard.name|swiftIdentifier|escapeReservedKeywords}}: String, StoryboardSegueType { - {% for segue in storyboard.segues %} - {% set segueID %}{{segue.identifier|swiftIdentifier}}{% endset %} - case {{segueID|escapeReservedKeywords}}{% if segueID != segue.identifier %} = "{{segue.identifier}}"{% endif %} - {% endfor %} - } - {% endfor %} -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} -{% else %} -// No storyboard found -{% endif %} diff --git a/templates/storyboards/osx-default.stencil b/templates/storyboards/macOS-swift2.stencil similarity index 100% rename from templates/storyboards/osx-default.stencil rename to templates/storyboards/macOS-swift2.stencil diff --git a/templates/storyboards/osx-swift3.stencil b/templates/storyboards/macOS-swift3.stencil similarity index 100% rename from templates/storyboards/osx-swift3.stencil rename to templates/storyboards/macOS-swift3.stencil diff --git a/templates/storyboards/osx-lowercase.stencil b/templates/storyboards/osx-lowercase.stencil deleted file mode 100644 index 000b959..0000000 --- a/templates/storyboards/osx-lowercase.stencil +++ /dev/null @@ -1,102 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -{% if storyboards %} -// swiftlint:disable sorted_imports -{% macro className scene %}{% if scene.customClass %}{% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}{% else %}NS{{scene.baseType}}{% endif %}{% endmacro %} -import Cocoa -import Foundation -{% for module in modules where module != env.PRODUCT_MODULE_NAME and module != param.module %} -import {{module}} -{% endfor %} - -// swiftlint:disable file_length - -{# This first part of the code is static, same every time whatever Storyboard you have #} -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> NSStoryboard { - return NSStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialController() -> AnyObject { - guard let controller = storyboard().instantiateInitialController() - else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return controller - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func controller() -> AnyObject { - return Self.storyboard().instantiateControllerWithIdentifier(self.rawValue) - } - static func controller(identifier: Self) -> AnyObject { - return identifier.controller() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension NSWindowController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -extension NSViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -{# This is where the generation begins, this code depends on what you have in your Storyboards #} -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -{% set sceneEnumName %}{{param.sceneEnumName|default:"StoryboardScene"}}{% endset %} -enum {{sceneEnumName}} { - {% for storyboard in storyboards %} - {% set storyboardName %}{{storyboard.name|swiftIdentifier|escapeReservedKeywords}}{% endset %} - {% if storyboard.scenes %} - enum {{storyboardName}}: String, StoryboardSceneType { - static let storyboardName = "{{storyboard.name}}" - {% for scene in storyboard.scenes %} - {% set sceneID %}{{scene.identifier|swiftIdentifier|lowerFirstWord}}{% endset %} - - case {{sceneID}}Scene = "{{scene.identifier}}" - {% set sceneClass %}{% call className scene %}{% endset %} - static func instantiate{{sceneID||snakeToCamelCase}}() -> {{sceneClass}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}Scene.controller() as? {{sceneClass}} - else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class {{sceneClass}}.") - } - return vc - } - {% endfor %} - } - {% else %} - enum {{storyboardName}}: StoryboardSceneType { - static let storyboardName = "{{storyboard.name}}" - } - {% endif %} - {% endfor %} -} - -enum {{param.segueEnumName|default:"StoryboardSegue"}} { - {% for storyboard in storyboards where storyboard.segues %} - enum {{storyboard.name|swiftIdentifier|escapeReservedKeywords}}: String, StoryboardSegueType { - {% for segue in storyboard.segues %} - {% set segueID %}{{segue.identifier|swiftIdentifier}}{% endset %} - case {{segueID|escapeReservedKeywords}}{% if segueID != segue.identifier %} = "{{segue.identifier}}"{% endif %} - {% endfor %} - } - {% endfor %} -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} -{% else %} -// No storyboard found -{% endif %} diff --git a/templates/storyboards/default.stencil b/templates/storyboards/swift2.stencil similarity index 100% rename from templates/storyboards/default.stencil rename to templates/storyboards/swift2.stencil diff --git a/templates/storyboards/uppercase.stencil b/templates/storyboards/uppercase.stencil deleted file mode 100644 index 7f9c054..0000000 --- a/templates/storyboards/uppercase.stencil +++ /dev/null @@ -1,121 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -{% if storyboards %} -// swiftlint:disable sorted_imports -{% macro className scene %}{% if scene.customClass %}{% if scene.customModule %}{{scene.customModule}}.{% endif %}{{scene.customClass}}{% else %}UI{{scene.baseType}}{% endif %}{% endmacro %} -import Foundation -import UIKit -{% for module in modules where module != env.PRODUCT_MODULE_NAME and module != param.module %} -import {{module}} -{% endfor %} - -// swiftlint:disable file_length - -{# This first part of the code is static, same every time whatever Storyboard you have #} -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> UIStoryboard { - return UIStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialViewController() -> UIViewController { - guard let vc = storyboard().instantiateInitialViewController() else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func viewController() -> UIViewController { - return Self.storyboard().instantiateViewControllerWithIdentifier(self.rawValue) - } - static func viewController(identifier: Self) -> UIViewController { - return identifier.viewController() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension UIViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -{# This is where the generation begins, this code depends on what you have in your Storyboards #} -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -{% set sceneEnumName %}{{param.sceneEnumName|default:"StoryboardScene"}}{% endset %} -enum {{sceneEnumName}} { - {% for storyboard in storyboards %} - {% set storyboardName %}{{storyboard.name|swiftIdentifier|escapeReservedKeywords}}{% endset %} - {% if storyboard.scenes %} - enum {{storyboardName}}: String, StoryboardSceneType { - static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene and storyboard.initialScene.baseType != "ViewController" %} - {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} - - static func initialViewController() -> {{initialSceneClass}} { - guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - {% endif %} - {% for scene in storyboard.scenes %} - {% set sceneID %}{{scene.identifier|swiftIdentifier}}{% endset %} - - case {{sceneID|escapeReservedKeywords}}{% if sceneID != scene.identifier %} = "{{scene.identifier}}"{% endif %} - {% if scene.baseType != "ViewController" %} - {% set sceneClass %}{% call className scene %}{% endset %} - static func {{sceneID|snakeToCamelCase|lowerFirstWord}}ViewController() -> {{sceneClass}} { - guard let vc = {{sceneEnumName}}.{{storyboardName}}.{{sceneID|escapeReservedKeywords}}.viewController() as? {{sceneClass}} - else { - fatalError("ViewController '{{scene.identifier}}' is not of the expected class {{sceneClass}}.") - } - return vc - } - {% else %} - static func {{sceneID|snakeToCamelCase|lowerFirstWord}}ViewController() -> UIViewController { - return {{sceneEnumName}}.{{storyboardName}}.{{sceneID}}.viewController() - } - {% endif %} - {% endfor %} - } - {% else %} - enum {{storyboardName}}: StoryboardSceneType { - static let storyboardName = "{{storyboard.name}}" - {% if storyboard.initialScene and storyboard.initialScene.baseType != "ViewController" %} - {% set initialSceneClass %}{% call className storyboard.initialScene %}{% endset %} - - static func initialViewController() -> {{initialSceneClass}} { - guard let vc = storyboard().instantiateInitialViewController() as? {{initialSceneClass}} else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - {% endif %} - } - {% endif %} - {% endfor %} -} - -enum {{param.segueEnumName|default:"StoryboardSegue"}} { - {% for storyboard in storyboards where storyboard.segues %} - enum {{storyboard.name|swiftIdentifier|escapeReservedKeywords}}: String, StoryboardSegueType { - {% for segue in storyboard.segues %} - {% set segueID %}{{segue.identifier|swiftIdentifier}}{% endset %} - case {{segueID|escapeReservedKeywords}}{% if segueID != segue.identifier %} = "{{segue.identifier}}"{% endif %} - {% endfor %} - } - {% endfor %} -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} -{% else %} -// No storyboard found -{% endif %} diff --git a/templates/strings/dot-syntax.stencil b/templates/strings/dot-syntax-swift2.stencil similarity index 100% rename from templates/strings/dot-syntax.stencil rename to templates/strings/dot-syntax-swift2.stencil diff --git a/templates/strings/default.stencil b/templates/strings/flat-swift2.stencil similarity index 100% rename from templates/strings/default.stencil rename to templates/strings/flat-swift2.stencil diff --git a/templates/strings/swift3.stencil b/templates/strings/flat-swift3.stencil similarity index 100% rename from templates/strings/swift3.stencil rename to templates/strings/flat-swift3.stencil diff --git a/templates/strings/genstrings.stencil b/templates/strings/genstrings.stencil deleted file mode 100644 index 6e5da83..0000000 --- a/templates/strings/genstrings.stencil +++ /dev/null @@ -1,63 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -{% if tables.first.levels %} -import Foundation - -// swiftlint:disable file_length -{% macro recursiveBlock item %} - {% for string in item.strings %} - /// {{string.translation}} - case {{string.key|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}{% if string.types %}({{string.types|join:", "}}){% endif %} - {% endfor %} - {% for child in item.children %} - {% call recursiveBlock child %} - {% endfor %} -{% endmacro %} - -// swiftlint:disable identifier_name line_length type_body_length -{% set enumName %}{{param.enumName|default:"L10n"}}{% endset %} -enum {{enumName}} { - {% call recursiveBlock tables.first.levels %} -} - -{% macro parametersBlock types %}{% for type in types %}let p{{forloop.counter}}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %} -{% macro argumentsBlock types %}{% for type in types %}p{{forloop.counter}}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %} -{% macro recursiveBlock item %} - {% for string in item.strings %} - {% if string.types %} - case .{{string.key|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}({% call parametersBlock string.types %}): - let format = NSLocalizedString("{{string.key}}", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return {{enumName}}.tr(format, {% call argumentsBlock string.types %}) - {% else %} - case .{{string.key|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}: - let format = NSLocalizedString("{{string.key}}", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return {{enumName}}.tr(format) - {% endif %} - {% endfor %} - {% for child in item.children %} - {% call recursiveBlock child %} - {% endfor %} -{% endmacro %} -extension {{enumName}}: CustomStringConvertible { - var description: String { return self.string } - - var string: String { - switch self { - {% call recursiveBlock tables.first.levels %} - } - } - - private static func tr(format: String, _ args: CVarArgType...) -> String { - return String(format: format, locale: NSLocale.currentLocale(), arguments: args) - } -} -// swiftlint:enable identifier_name line_length type_body_length - -func tr(key: {{enumName}}) -> String { - return key.string -} - -private final class BundleToken {} -{% else %} -// No string found -{% endif %} diff --git a/templates/strings/no-comments-swift3.stencil b/templates/strings/no-comments-swift3.stencil deleted file mode 100644 index ed43b5d..0000000 --- a/templates/strings/no-comments-swift3.stencil +++ /dev/null @@ -1,61 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -{% if tables.first.levels %} -import Foundation - -// swiftlint:disable file_length -{% macro recursiveBlock item %} - {% for string in item.strings %} - case {{string.key|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}}{% if string.types %}({{string.types|join:", "}}){% endif %} - {% endfor %} - {% for child in item.children %} - {% call recursiveBlock child %} - {% endfor %} -{% endmacro %} - -// swiftlint:disable identifier_name line_length type_body_length -{% set enumName %}{{param.enumName|default:"L10n"}}{% endset %} -enum {{enumName}} { - {% call recursiveBlock tables.first.levels %} -} - -{% macro parametersBlock types %}{% for type in types %}let p{{forloop.counter}}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %} -{% macro argumentsBlock types %}{% for type in types %}p{{forloop.counter}}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %} -{% macro recursiveBlock item %} - {% for string in item.strings %} - {% if string.types %} - case .{{string.key|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}}({% call parametersBlock string.types %}): - return {{enumName}}.tr(key: "{{string.key}}", {% call argumentsBlock string.types %}) - {% else %} - case .{{string.key|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}}: - return {{enumName}}.tr(key: "{{string.key}}") - {% endif %} - {% endfor %} - {% for child in item.children %} - {% call recursiveBlock child %} - {% endfor %} -{% endmacro %} -extension {{enumName}}: CustomStringConvertible { - var description: String { return self.string } - - var string: String { - switch self { - {% call recursiveBlock tables.first.levels %} - } - } - - private static func tr(key: String, _ args: CVarArg...) -> String { - let format = NSLocalizedString(key, bundle: Bundle(for: BundleToken.self), comment: "") - return String(format: format, locale: Locale.current, arguments: args) - } -} -// swiftlint:enable identifier_name line_length type_body_length - -func tr(_ key: {{enumName}}) -> String { - return key.string -} - -private final class BundleToken {} -{% else %} -// No string found -{% endif %} diff --git a/templates/strings/structured.stencil b/templates/strings/structured.stencil deleted file mode 100644 index edfeaf3..0000000 --- a/templates/strings/structured.stencil +++ /dev/null @@ -1,74 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -{% if tables.first.levels %} -import Foundation - -// swiftlint:disable file_length - -// swiftlint:disable identifier_name line_length nesting type_body_length -{% set enumName %}{{param.enumName|default:"L10n"}}{% endset %} -enum {{enumName}} { -{% macro enumBlock item sp %} -{{sp}} {% for string in item.strings %} -{{sp}} /// {{string.translation}} -{{sp}} case {{string.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}{% if string.types %}({{string.types|join:", "}}){% endif %} -{{sp}} {% endfor %} -{{sp}} {% for child in item.children %} - -{{sp}} case {{child.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}({{child.name|swiftIdentifier|snakeToCamelCase}}{{enumName}}) -{{sp}} enum {{child.name|swiftIdentifier|snakeToCamelCase}}{{enumName}} { -{{sp}} {% set sp2 %}{{sp}} {% endset %} -{{sp}} {% call enumBlock child sp2 %} -{{sp}} } -{{sp}} {% endfor %} -{% endmacro %} - {% call enumBlock tables.first.levels sp %} -} - -extension {{enumName}}: CustomStringConvertible { -{% macro parametersBlock types %}{% for type in types %}let p{{forloop.counter}}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %} -{% macro argumentsBlock types %}{% for type in types %}p{{forloop.counter}}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %} -{% macro extensionBlock item sp keySuffix %} -{{sp}} {% for string in item.strings %} -{{sp}} {% if string.types %} -{{sp}} case .{{string.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}({% call parametersBlock string.types %}): -{{sp}} return {{enumName}}.tr("{{string.key}}", {% call argumentsBlock string.types %}) -{{sp}} {% else %} -{{sp}} case .{{string.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}: -{{sp}} return {{enumName}}.tr("{{string.key}}") -{{sp}} {% endif %} -{{sp}} {% endfor %} -{{sp}} {% for child in item.children %} -{{sp}} {% set subkey %}levelSub{{keySuffix}}Key{{child.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}{% endset %} -{{sp}} case .{{child.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}(let {{subkey}}): - -{{sp}} switch {{subkey}} { -{{sp}} {% set sp2 %}{{sp}} {% endset %} -{{sp}} {% set keySuffix %}{{keySuffix}}Sub{% endset %} -{{sp}} {% call extensionBlock child sp2 keySuffix %} -{{sp}} } -{{sp}} {% endfor %} -{% endmacro %} - var description: String { return self.string } - - var string: String { - switch self { - {% call extensionBlock tables.first.levels " " keySuffix %} - } - } - - private static func tr(key: String, _ args: CVarArgType...) -> String { - let format = NSLocalizedString(key, bundle: NSBundle(forClass: BundleToken.self), comment: "") - return String(format: format, locale: NSLocale.currentLocale(), arguments: args) - } -} -// swiftlint:enable identifier_name line_length nesting type_body_length - -func tr(key: {{enumName}}) -> String { - return key.string -} - -private final class BundleToken {} -{% else %} -// No string found -{% endif %} From de31d4844450460da5f9a8aa178080d49ee6d66f Mon Sep 17 00:00:00 2001 From: David Jennes Date: Thu, 11 May 2017 21:56:15 +0200 Subject: [PATCH 02/12] update output files --- ...rawValue-context-defaults-customname.swift | 51 ----- .../Colors/rawValue-context-defaults.swift | 51 ----- .../Colors/rawValue-context-empty.swift | 3 - ... swift2-context-defaults-customname.swift} | 0 ...ts.swift => swift2-context-defaults.swift} | 0 ...empty.swift => swift2-context-empty.swift} | 0 ...ift => swift2-context-text-defaults.swift} | 0 ... swift2-context-defaults-customname.swift} | 0 ...ts.swift => swift2-context-defaults.swift} | 0 ...empty.swift => swift2-context-empty.swift} | 0 ...llvalues-context-defaults-customname.swift | 64 ------ .../Images/allvalues-context-defaults.swift | 64 ------ .../default-context-defaults-customname.swift | 52 ----- .../Images/default-context-defaults.swift | 52 ----- .../Images/default-context-empty.swift | 3 - .../Images/dot-syntax-context-empty.swift | 3 - ...x-swift3-context-defaults-customname.swift | 74 ------- .../dot-syntax-swift3-context-defaults.swift | 74 ------- .../dot-syntax-swift3-context-empty.swift | 3 - ... swift2-context-defaults-customname.swift} | 0 ...ts.swift => swift2-context-defaults.swift} | 0 ...empty.swift => swift2-context-empty.swift} | 0 .../swift3-context-defaults-customname.swift | 62 ++++-- .../Images/swift3-context-defaults.swift | 62 ++++-- .../lowercase-context-all-customname.swift | 188 ---------------- .../lowercase-context-all-ignore-module.swift | 187 ---------------- .../lowercase-context-all.swift | 188 ---------------- ...ft => swift2-context-all-customname.swift} | 0 ...=> swift2-context-all-ignore-module.swift} | 0 ...ext-all.swift => swift2-context-all.swift} | 0 ...empty.swift => swift2-context-empty.swift} | 0 .../uppercase-context-all-customname.swift | 188 ---------------- .../uppercase-context-all-ignore-module.swift | 187 ---------------- .../uppercase-context-all.swift | 188 ---------------- .../uppercase-context-empty.swift | 3 - .../default-context-empty.swift | 3 - .../lowercase-context-all-customname.swift | 173 --------------- .../lowercase-context-all-ignore-module.swift | 172 --------------- .../lowercase-context-all.swift | 173 --------------- .../lowercase-context-empty.swift | 3 - ...ft => swift2-context-all-customname.swift} | 0 ...=> swift2-context-all-ignore-module.swift} | 0 ...ext-all.swift => swift2-context-all.swift} | 0 .../swift2-context-empty.swift} | 0 ...-swift2-context-defaults-customname.swift} | 0 ... dot-syntax-swift2-context-defaults.swift} | 0 ... => dot-syntax-swift2-context-empty.swift} | 0 ...-swift2-context-defaults-customname.swift} | 0 ...ift => flat-swift2-context-defaults.swift} | 0 ....swift => flat-swift2-context-empty.swift} | 0 ...-swift3-context-defaults-customname.swift} | 0 ...ift => flat-swift3-context-defaults.swift} | 0 ....swift => flat-swift3-context-empty.swift} | 0 ...nstrings-context-defaults-customname.swift | 84 -------- .../Strings/genstrings-context-defaults.swift | 84 -------- ...s-swift3-context-defaults-customname.swift | 63 ------ .../no-comments-swift3-context-defaults.swift | 63 ------ .../no-comments-swift3-context-empty.swift | 3 - ...ructured-context-defaults-customname.swift | 202 ------------------ .../Strings/structured-context-defaults.swift | 202 ------------------ .../Strings/structured-context-empty.swift | 3 - .../Strings/swift3-context-empty.swift | 3 - 62 files changed, 84 insertions(+), 2894 deletions(-) delete mode 100644 Tests/Expected/Colors/rawValue-context-defaults-customname.swift delete mode 100644 Tests/Expected/Colors/rawValue-context-defaults.swift delete mode 100644 Tests/Expected/Colors/rawValue-context-empty.swift rename Tests/Expected/Colors/{default-context-defaults-customname.swift => swift2-context-defaults-customname.swift} (100%) rename Tests/Expected/Colors/{default-context-defaults.swift => swift2-context-defaults.swift} (100%) rename Tests/Expected/Colors/{default-context-empty.swift => swift2-context-empty.swift} (100%) rename Tests/Expected/Colors/{default-context-text-defaults.swift => swift2-context-text-defaults.swift} (100%) rename Tests/Expected/Fonts/{default-context-defaults-customname.swift => swift2-context-defaults-customname.swift} (100%) rename Tests/Expected/Fonts/{default-context-defaults.swift => swift2-context-defaults.swift} (100%) rename Tests/Expected/Fonts/{default-context-empty.swift => swift2-context-empty.swift} (100%) delete mode 100644 Tests/Expected/Images/allvalues-context-defaults-customname.swift delete mode 100644 Tests/Expected/Images/allvalues-context-defaults.swift delete mode 100644 Tests/Expected/Images/default-context-defaults-customname.swift delete mode 100644 Tests/Expected/Images/default-context-defaults.swift delete mode 100644 Tests/Expected/Images/default-context-empty.swift delete mode 100644 Tests/Expected/Images/dot-syntax-context-empty.swift delete mode 100644 Tests/Expected/Images/dot-syntax-swift3-context-defaults-customname.swift delete mode 100644 Tests/Expected/Images/dot-syntax-swift3-context-defaults.swift delete mode 100644 Tests/Expected/Images/dot-syntax-swift3-context-empty.swift rename Tests/Expected/Images/{dot-syntax-context-defaults-customname.swift => swift2-context-defaults-customname.swift} (100%) rename Tests/Expected/Images/{dot-syntax-context-defaults.swift => swift2-context-defaults.swift} (100%) rename Tests/Expected/Images/{allvalues-context-empty.swift => swift2-context-empty.swift} (100%) delete mode 100644 Tests/Expected/Storyboards-iOS/lowercase-context-all-customname.swift delete mode 100644 Tests/Expected/Storyboards-iOS/lowercase-context-all-ignore-module.swift delete mode 100644 Tests/Expected/Storyboards-iOS/lowercase-context-all.swift rename Tests/Expected/Storyboards-iOS/{default-context-all-customname.swift => swift2-context-all-customname.swift} (100%) rename Tests/Expected/Storyboards-iOS/{default-context-all-ignore-module.swift => swift2-context-all-ignore-module.swift} (100%) rename Tests/Expected/Storyboards-iOS/{default-context-all.swift => swift2-context-all.swift} (100%) rename Tests/Expected/Storyboards-iOS/{default-context-empty.swift => swift2-context-empty.swift} (100%) delete mode 100644 Tests/Expected/Storyboards-iOS/uppercase-context-all-customname.swift delete mode 100644 Tests/Expected/Storyboards-iOS/uppercase-context-all-ignore-module.swift delete mode 100644 Tests/Expected/Storyboards-iOS/uppercase-context-all.swift delete mode 100644 Tests/Expected/Storyboards-iOS/uppercase-context-empty.swift delete mode 100644 Tests/Expected/Storyboards-macOS/default-context-empty.swift delete mode 100644 Tests/Expected/Storyboards-macOS/lowercase-context-all-customname.swift delete mode 100644 Tests/Expected/Storyboards-macOS/lowercase-context-all-ignore-module.swift delete mode 100644 Tests/Expected/Storyboards-macOS/lowercase-context-all.swift delete mode 100644 Tests/Expected/Storyboards-macOS/lowercase-context-empty.swift rename Tests/Expected/Storyboards-macOS/{default-context-all-customname.swift => swift2-context-all-customname.swift} (100%) rename Tests/Expected/Storyboards-macOS/{default-context-all-ignore-module.swift => swift2-context-all-ignore-module.swift} (100%) rename Tests/Expected/Storyboards-macOS/{default-context-all.swift => swift2-context-all.swift} (100%) rename Tests/Expected/{Storyboards-iOS/lowercase-context-empty.swift => Storyboards-macOS/swift2-context-empty.swift} (100%) rename Tests/Expected/Strings/{dot-syntax-context-defaults-customname.swift => dot-syntax-swift2-context-defaults-customname.swift} (100%) rename Tests/Expected/Strings/{dot-syntax-context-defaults.swift => dot-syntax-swift2-context-defaults.swift} (100%) rename Tests/Expected/Strings/{default-context-empty.swift => dot-syntax-swift2-context-empty.swift} (100%) rename Tests/Expected/Strings/{default-context-defaults-customname.swift => flat-swift2-context-defaults-customname.swift} (100%) rename Tests/Expected/Strings/{default-context-defaults.swift => flat-swift2-context-defaults.swift} (100%) rename Tests/Expected/Strings/{dot-syntax-context-empty.swift => flat-swift2-context-empty.swift} (100%) rename Tests/Expected/Strings/{swift3-context-defaults-customname.swift => flat-swift3-context-defaults-customname.swift} (100%) rename Tests/Expected/Strings/{swift3-context-defaults.swift => flat-swift3-context-defaults.swift} (100%) rename Tests/Expected/Strings/{genstrings-context-empty.swift => flat-swift3-context-empty.swift} (100%) delete mode 100644 Tests/Expected/Strings/genstrings-context-defaults-customname.swift delete mode 100644 Tests/Expected/Strings/genstrings-context-defaults.swift delete mode 100644 Tests/Expected/Strings/no-comments-swift3-context-defaults-customname.swift delete mode 100644 Tests/Expected/Strings/no-comments-swift3-context-defaults.swift delete mode 100644 Tests/Expected/Strings/no-comments-swift3-context-empty.swift delete mode 100644 Tests/Expected/Strings/structured-context-defaults-customname.swift delete mode 100644 Tests/Expected/Strings/structured-context-defaults.swift delete mode 100644 Tests/Expected/Strings/structured-context-empty.swift delete mode 100644 Tests/Expected/Strings/swift3-context-empty.swift diff --git a/Tests/Expected/Colors/rawValue-context-defaults-customname.swift b/Tests/Expected/Colors/rawValue-context-defaults-customname.swift deleted file mode 100644 index 7187859..0000000 --- a/Tests/Expected/Colors/rawValue-context-defaults-customname.swift +++ /dev/null @@ -1,51 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -#if os(OSX) - import AppKit.NSColor - typealias Color = NSColor -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIColor - typealias Color = UIColor -#endif - -// swiftlint:disable file_length - -// swiftlint:disable operator_usage_whitespace -extension Color { - convenience init(rgbaValue: UInt32) { - let red = CGFloat((rgbaValue >> 24) & 0xff) / 255.0 - let green = CGFloat((rgbaValue >> 16) & 0xff) / 255.0 - let blue = CGFloat((rgbaValue >> 8) & 0xff) / 255.0 - let alpha = CGFloat((rgbaValue ) & 0xff) / 255.0 - - self.init(red: red, green: green, blue: blue, alpha: alpha) - } -} -// swiftlint:enable operator_usage_whitespace - -// swiftlint:disable identifier_name line_length type_body_length -enum XCTColors: UInt32 { - /// - /// Alpha: 100%
(0x339666ff) - case ArticleBody = 0x339666ff - /// - /// Alpha: 100%
(0xff66ccff) - case ArticleFootnote = 0xff66ccff - /// - /// Alpha: 100%
(0x33fe66ff) - case ArticleTitle = 0x33fe66ff - /// - /// Alpha: 80%
(0xffffffcc) - case Private = 0xffffffcc - - var color: Color { - return Color(named: self) - } -} -// swiftlint:enable identifier_name line_length type_body_length - -extension Color { - convenience init(named name: XCTColors) { - self.init(rgbaValue: name.rawValue) - } -} diff --git a/Tests/Expected/Colors/rawValue-context-defaults.swift b/Tests/Expected/Colors/rawValue-context-defaults.swift deleted file mode 100644 index 71b732c..0000000 --- a/Tests/Expected/Colors/rawValue-context-defaults.swift +++ /dev/null @@ -1,51 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -#if os(OSX) - import AppKit.NSColor - typealias Color = NSColor -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIColor - typealias Color = UIColor -#endif - -// swiftlint:disable file_length - -// swiftlint:disable operator_usage_whitespace -extension Color { - convenience init(rgbaValue: UInt32) { - let red = CGFloat((rgbaValue >> 24) & 0xff) / 255.0 - let green = CGFloat((rgbaValue >> 16) & 0xff) / 255.0 - let blue = CGFloat((rgbaValue >> 8) & 0xff) / 255.0 - let alpha = CGFloat((rgbaValue ) & 0xff) / 255.0 - - self.init(red: red, green: green, blue: blue, alpha: alpha) - } -} -// swiftlint:enable operator_usage_whitespace - -// swiftlint:disable identifier_name line_length type_body_length -enum ColorName: UInt32 { - /// - /// Alpha: 100%
(0x339666ff) - case ArticleBody = 0x339666ff - /// - /// Alpha: 100%
(0xff66ccff) - case ArticleFootnote = 0xff66ccff - /// - /// Alpha: 100%
(0x33fe66ff) - case ArticleTitle = 0x33fe66ff - /// - /// Alpha: 80%
(0xffffffcc) - case Private = 0xffffffcc - - var color: Color { - return Color(named: self) - } -} -// swiftlint:enable identifier_name line_length type_body_length - -extension Color { - convenience init(named name: ColorName) { - self.init(rgbaValue: name.rawValue) - } -} diff --git a/Tests/Expected/Colors/rawValue-context-empty.swift b/Tests/Expected/Colors/rawValue-context-empty.swift deleted file mode 100644 index 129ff35..0000000 --- a/Tests/Expected/Colors/rawValue-context-empty.swift +++ /dev/null @@ -1,3 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// No color found diff --git a/Tests/Expected/Colors/default-context-defaults-customname.swift b/Tests/Expected/Colors/swift2-context-defaults-customname.swift similarity index 100% rename from Tests/Expected/Colors/default-context-defaults-customname.swift rename to Tests/Expected/Colors/swift2-context-defaults-customname.swift diff --git a/Tests/Expected/Colors/default-context-defaults.swift b/Tests/Expected/Colors/swift2-context-defaults.swift similarity index 100% rename from Tests/Expected/Colors/default-context-defaults.swift rename to Tests/Expected/Colors/swift2-context-defaults.swift diff --git a/Tests/Expected/Colors/default-context-empty.swift b/Tests/Expected/Colors/swift2-context-empty.swift similarity index 100% rename from Tests/Expected/Colors/default-context-empty.swift rename to Tests/Expected/Colors/swift2-context-empty.swift diff --git a/Tests/Expected/Colors/default-context-text-defaults.swift b/Tests/Expected/Colors/swift2-context-text-defaults.swift similarity index 100% rename from Tests/Expected/Colors/default-context-text-defaults.swift rename to Tests/Expected/Colors/swift2-context-text-defaults.swift diff --git a/Tests/Expected/Fonts/default-context-defaults-customname.swift b/Tests/Expected/Fonts/swift2-context-defaults-customname.swift similarity index 100% rename from Tests/Expected/Fonts/default-context-defaults-customname.swift rename to Tests/Expected/Fonts/swift2-context-defaults-customname.swift diff --git a/Tests/Expected/Fonts/default-context-defaults.swift b/Tests/Expected/Fonts/swift2-context-defaults.swift similarity index 100% rename from Tests/Expected/Fonts/default-context-defaults.swift rename to Tests/Expected/Fonts/swift2-context-defaults.swift diff --git a/Tests/Expected/Fonts/default-context-empty.swift b/Tests/Expected/Fonts/swift2-context-empty.swift similarity index 100% rename from Tests/Expected/Fonts/default-context-empty.swift rename to Tests/Expected/Fonts/swift2-context-empty.swift diff --git a/Tests/Expected/Images/allvalues-context-defaults-customname.swift b/Tests/Expected/Images/allvalues-context-defaults-customname.swift deleted file mode 100644 index dadc473..0000000 --- a/Tests/Expected/Images/allvalues-context-defaults-customname.swift +++ /dev/null @@ -1,64 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -#if os(OSX) - import AppKit.NSImage - typealias Image = NSImage -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIImage - typealias Image = UIImage -#endif - -// swiftlint:disable file_length - -// swiftlint:disable identifier_name line_length type_body_length -enum XCTImages: String { - case Exotic_Banana = "Exotic/Banana" - case Exotic_Mango = "Exotic/Mango" - case Private = "private" - case Round_Apricot = "Round/Apricot" - case Round_Orange = "Round/Orange" - case Round_Apple = "Round/Apple" - case Round_Double_Cherry = "Round/Double/Cherry" - case Round_Tomato = "Round/Tomato" - - // swiftlint:disable:next explicit_type_interface - static let allValues = [ - Exotic_Banana, - Exotic_Mango, - Private, - Round_Apricot, - Round_Orange, - Round_Apple, - Round_Double_Cherry, - Round_Tomato - ] -} -// swiftlint:enable identifier_name line_length type_body_length - -extension XCTImages { - var image: Image { - let bundle = NSBundle(forClass: BundleToken.self) - #if os(iOS) || os(tvOS) - let image = Image(named: rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) - let image = bundle.imageForResource(rawValue) - #elseif os(watchOS) - let image = Image(named: rawValue) - #endif - guard let result = image else { fatalError("Unable to load image \(rawValue).") } - return result - } -} - -extension Image { - convenience init!(asset: XCTImages) { - #if os(iOS) || os(tvOS) - let bundle = NSBundle(forClass: BundleToken.self) - self.init(named: asset.rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) || os(watchOS) - self.init(named: asset.rawValue) - #endif - } -} - -private final class BundleToken {} diff --git a/Tests/Expected/Images/allvalues-context-defaults.swift b/Tests/Expected/Images/allvalues-context-defaults.swift deleted file mode 100644 index 854de53..0000000 --- a/Tests/Expected/Images/allvalues-context-defaults.swift +++ /dev/null @@ -1,64 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -#if os(OSX) - import AppKit.NSImage - typealias Image = NSImage -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIImage - typealias Image = UIImage -#endif - -// swiftlint:disable file_length - -// swiftlint:disable identifier_name line_length type_body_length -enum Asset: String { - case Exotic_Banana = "Exotic/Banana" - case Exotic_Mango = "Exotic/Mango" - case Private = "private" - case Round_Apricot = "Round/Apricot" - case Round_Orange = "Round/Orange" - case Round_Apple = "Round/Apple" - case Round_Double_Cherry = "Round/Double/Cherry" - case Round_Tomato = "Round/Tomato" - - // swiftlint:disable:next explicit_type_interface - static let allValues = [ - Exotic_Banana, - Exotic_Mango, - Private, - Round_Apricot, - Round_Orange, - Round_Apple, - Round_Double_Cherry, - Round_Tomato - ] -} -// swiftlint:enable identifier_name line_length type_body_length - -extension Asset { - var image: Image { - let bundle = NSBundle(forClass: BundleToken.self) - #if os(iOS) || os(tvOS) - let image = Image(named: rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) - let image = bundle.imageForResource(rawValue) - #elseif os(watchOS) - let image = Image(named: rawValue) - #endif - guard let result = image else { fatalError("Unable to load image \(rawValue).") } - return result - } -} - -extension Image { - convenience init!(asset: Asset) { - #if os(iOS) || os(tvOS) - let bundle = NSBundle(forClass: BundleToken.self) - self.init(named: asset.rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) || os(watchOS) - self.init(named: asset.rawValue) - #endif - } -} - -private final class BundleToken {} diff --git a/Tests/Expected/Images/default-context-defaults-customname.swift b/Tests/Expected/Images/default-context-defaults-customname.swift deleted file mode 100644 index 643f525..0000000 --- a/Tests/Expected/Images/default-context-defaults-customname.swift +++ /dev/null @@ -1,52 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -#if os(OSX) - import AppKit.NSImage - typealias Image = NSImage -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIImage - typealias Image = UIImage -#endif - -// swiftlint:disable file_length - -// swiftlint:disable identifier_name line_length type_body_length -enum XCTImages: String { - case Exotic_Banana = "Exotic/Banana" - case Exotic_Mango = "Exotic/Mango" - case Private = "private" - case Round_Apricot = "Round/Apricot" - case Round_Orange = "Round/Orange" - case Round_Apple = "Round/Apple" - case Round_Double_Cherry = "Round/Double/Cherry" - case Round_Tomato = "Round/Tomato" -} -// swiftlint:enable identifier_name line_length type_body_length - -extension XCTImages { - var image: Image { - let bundle = NSBundle(forClass: BundleToken.self) - #if os(iOS) || os(tvOS) - let image = Image(named: rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) - let image = bundle.imageForResource(rawValue) - #elseif os(watchOS) - let image = Image(named: rawValue) - #endif - guard let result = image else { fatalError("Unable to load image \(rawValue).") } - return result - } -} - -extension Image { - convenience init!(asset: XCTImages) { - #if os(iOS) || os(tvOS) - let bundle = NSBundle(forClass: BundleToken.self) - self.init(named: asset.rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) || os(watchOS) - self.init(named: asset.rawValue) - #endif - } -} - -private final class BundleToken {} diff --git a/Tests/Expected/Images/default-context-defaults.swift b/Tests/Expected/Images/default-context-defaults.swift deleted file mode 100644 index 0464bb8..0000000 --- a/Tests/Expected/Images/default-context-defaults.swift +++ /dev/null @@ -1,52 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -#if os(OSX) - import AppKit.NSImage - typealias Image = NSImage -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIImage - typealias Image = UIImage -#endif - -// swiftlint:disable file_length - -// swiftlint:disable identifier_name line_length type_body_length -enum Asset: String { - case Exotic_Banana = "Exotic/Banana" - case Exotic_Mango = "Exotic/Mango" - case Private = "private" - case Round_Apricot = "Round/Apricot" - case Round_Orange = "Round/Orange" - case Round_Apple = "Round/Apple" - case Round_Double_Cherry = "Round/Double/Cherry" - case Round_Tomato = "Round/Tomato" -} -// swiftlint:enable identifier_name line_length type_body_length - -extension Asset { - var image: Image { - let bundle = NSBundle(forClass: BundleToken.self) - #if os(iOS) || os(tvOS) - let image = Image(named: rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) - let image = bundle.imageForResource(rawValue) - #elseif os(watchOS) - let image = Image(named: rawValue) - #endif - guard let result = image else { fatalError("Unable to load image \(rawValue).") } - return result - } -} - -extension Image { - convenience init!(asset: Asset) { - #if os(iOS) || os(tvOS) - let bundle = NSBundle(forClass: BundleToken.self) - self.init(named: asset.rawValue, inBundle: bundle, compatibleWithTraitCollection: nil) - #elseif os(OSX) || os(watchOS) - self.init(named: asset.rawValue) - #endif - } -} - -private final class BundleToken {} diff --git a/Tests/Expected/Images/default-context-empty.swift b/Tests/Expected/Images/default-context-empty.swift deleted file mode 100644 index 3901563..0000000 --- a/Tests/Expected/Images/default-context-empty.swift +++ /dev/null @@ -1,3 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// No image found diff --git a/Tests/Expected/Images/dot-syntax-context-empty.swift b/Tests/Expected/Images/dot-syntax-context-empty.swift deleted file mode 100644 index 3901563..0000000 --- a/Tests/Expected/Images/dot-syntax-context-empty.swift +++ /dev/null @@ -1,3 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// No image found diff --git a/Tests/Expected/Images/dot-syntax-swift3-context-defaults-customname.swift b/Tests/Expected/Images/dot-syntax-swift3-context-defaults-customname.swift deleted file mode 100644 index cef531a..0000000 --- a/Tests/Expected/Images/dot-syntax-swift3-context-defaults-customname.swift +++ /dev/null @@ -1,74 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -#if os(OSX) - import AppKit.NSImage - typealias Image = NSImage -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIImage - typealias Image = UIImage -#endif - -// swiftlint:disable file_length - -struct XCTImagesType: ExpressibleByStringLiteral { - fileprivate var value: String - - var image: Image { - let bundle = Bundle(for: BundleToken.self) - #if os(iOS) || os(tvOS) - let image = Image(named: value, in: bundle, compatibleWith: nil) - #elseif os(OSX) - let image = bundle.image(forResource: value) - #elseif os(watchOS) - let image = Image(named: value) - #endif - guard let result = image else { fatalError("Unable to load image \(value).") } - return result - } - - init(stringLiteral value: String) { - self.value = value - } - - init(extendedGraphemeClusterLiteral value: String) { - self.init(stringLiteral: value) - } - - init(unicodeScalarLiteral value: String) { - self.init(stringLiteral: value) - } -} - -// swiftlint:disable identifier_name line_length nesting type_body_length type_name -enum XCTImages { - enum Exotic { - static let banana: XCTImagesType = "Exotic/Banana" - static let mango: XCTImagesType = "Exotic/Mango" - } - static let `private`: XCTImagesType = "private" - enum Round { - static let apricot: XCTImagesType = "Round/Apricot" - static let orange: XCTImagesType = "Round/Orange" - enum Red { - static let apple: XCTImagesType = "Round/Apple" - enum Double { - static let cherry: XCTImagesType = "Round/Double/Cherry" - } - static let tomato: XCTImagesType = "Round/Tomato" - } - } -} -// swiftlint:enable identifier_name line_length nesting type_body_length type_name - -extension Image { - convenience init!(asset: XCTImagesType) { - #if os(iOS) || os(tvOS) - let bundle = Bundle(for: BundleToken.self) - self.init(named: asset.value, in: bundle, compatibleWith: nil) - #elseif os(OSX) || os(watchOS) - self.init(named: asset.value) - #endif - } -} - -private final class BundleToken {} diff --git a/Tests/Expected/Images/dot-syntax-swift3-context-defaults.swift b/Tests/Expected/Images/dot-syntax-swift3-context-defaults.swift deleted file mode 100644 index 781c301..0000000 --- a/Tests/Expected/Images/dot-syntax-swift3-context-defaults.swift +++ /dev/null @@ -1,74 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -#if os(OSX) - import AppKit.NSImage - typealias Image = NSImage -#elseif os(iOS) || os(tvOS) || os(watchOS) - import UIKit.UIImage - typealias Image = UIImage -#endif - -// swiftlint:disable file_length - -struct AssetType: ExpressibleByStringLiteral { - fileprivate var value: String - - var image: Image { - let bundle = Bundle(for: BundleToken.self) - #if os(iOS) || os(tvOS) - let image = Image(named: value, in: bundle, compatibleWith: nil) - #elseif os(OSX) - let image = bundle.image(forResource: value) - #elseif os(watchOS) - let image = Image(named: value) - #endif - guard let result = image else { fatalError("Unable to load image \(value).") } - return result - } - - init(stringLiteral value: String) { - self.value = value - } - - init(extendedGraphemeClusterLiteral value: String) { - self.init(stringLiteral: value) - } - - init(unicodeScalarLiteral value: String) { - self.init(stringLiteral: value) - } -} - -// swiftlint:disable identifier_name line_length nesting type_body_length type_name -enum Asset { - enum Exotic { - static let banana: AssetType = "Exotic/Banana" - static let mango: AssetType = "Exotic/Mango" - } - static let `private`: AssetType = "private" - enum Round { - static let apricot: AssetType = "Round/Apricot" - static let orange: AssetType = "Round/Orange" - enum Red { - static let apple: AssetType = "Round/Apple" - enum Double { - static let cherry: AssetType = "Round/Double/Cherry" - } - static let tomato: AssetType = "Round/Tomato" - } - } -} -// swiftlint:enable identifier_name line_length nesting type_body_length type_name - -extension Image { - convenience init!(asset: AssetType) { - #if os(iOS) || os(tvOS) - let bundle = Bundle(for: BundleToken.self) - self.init(named: asset.value, in: bundle, compatibleWith: nil) - #elseif os(OSX) || os(watchOS) - self.init(named: asset.value) - #endif - } -} - -private final class BundleToken {} diff --git a/Tests/Expected/Images/dot-syntax-swift3-context-empty.swift b/Tests/Expected/Images/dot-syntax-swift3-context-empty.swift deleted file mode 100644 index 3901563..0000000 --- a/Tests/Expected/Images/dot-syntax-swift3-context-empty.swift +++ /dev/null @@ -1,3 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// No image found diff --git a/Tests/Expected/Images/dot-syntax-context-defaults-customname.swift b/Tests/Expected/Images/swift2-context-defaults-customname.swift similarity index 100% rename from Tests/Expected/Images/dot-syntax-context-defaults-customname.swift rename to Tests/Expected/Images/swift2-context-defaults-customname.swift diff --git a/Tests/Expected/Images/dot-syntax-context-defaults.swift b/Tests/Expected/Images/swift2-context-defaults.swift similarity index 100% rename from Tests/Expected/Images/dot-syntax-context-defaults.swift rename to Tests/Expected/Images/swift2-context-defaults.swift diff --git a/Tests/Expected/Images/allvalues-context-empty.swift b/Tests/Expected/Images/swift2-context-empty.swift similarity index 100% rename from Tests/Expected/Images/allvalues-context-empty.swift rename to Tests/Expected/Images/swift2-context-empty.swift diff --git a/Tests/Expected/Images/swift3-context-defaults-customname.swift b/Tests/Expected/Images/swift3-context-defaults-customname.swift index 535912c..cef531a 100644 --- a/Tests/Expected/Images/swift3-context-defaults-customname.swift +++ b/Tests/Expected/Images/swift3-context-defaults-customname.swift @@ -10,41 +10,63 @@ // swiftlint:disable file_length -// swiftlint:disable identifier_name line_length type_body_length -enum XCTImages: String { - case exoticBanana = "Exotic/Banana" - case exoticMango = "Exotic/Mango" - case `private` = "private" - case roundApricot = "Round/Apricot" - case roundOrange = "Round/Orange" - case roundApple = "Round/Apple" - case roundDoubleCherry = "Round/Double/Cherry" - case roundTomato = "Round/Tomato" -} -// swiftlint:enable identifier_name line_length type_body_length +struct XCTImagesType: ExpressibleByStringLiteral { + fileprivate var value: String -extension XCTImages { var image: Image { let bundle = Bundle(for: BundleToken.self) #if os(iOS) || os(tvOS) - let image = Image(named: rawValue, in: bundle, compatibleWith: nil) + let image = Image(named: value, in: bundle, compatibleWith: nil) #elseif os(OSX) - let image = bundle.image(forResource: rawValue) + let image = bundle.image(forResource: value) #elseif os(watchOS) - let image = Image(named: rawValue) + let image = Image(named: value) #endif - guard let result = image else { fatalError("Unable to load image \(rawValue).") } + guard let result = image else { fatalError("Unable to load image \(value).") } return result } + + init(stringLiteral value: String) { + self.value = value + } + + init(extendedGraphemeClusterLiteral value: String) { + self.init(stringLiteral: value) + } + + init(unicodeScalarLiteral value: String) { + self.init(stringLiteral: value) + } +} + +// swiftlint:disable identifier_name line_length nesting type_body_length type_name +enum XCTImages { + enum Exotic { + static let banana: XCTImagesType = "Exotic/Banana" + static let mango: XCTImagesType = "Exotic/Mango" + } + static let `private`: XCTImagesType = "private" + enum Round { + static let apricot: XCTImagesType = "Round/Apricot" + static let orange: XCTImagesType = "Round/Orange" + enum Red { + static let apple: XCTImagesType = "Round/Apple" + enum Double { + static let cherry: XCTImagesType = "Round/Double/Cherry" + } + static let tomato: XCTImagesType = "Round/Tomato" + } + } } +// swiftlint:enable identifier_name line_length nesting type_body_length type_name extension Image { - convenience init!(asset: XCTImages) { + convenience init!(asset: XCTImagesType) { #if os(iOS) || os(tvOS) let bundle = Bundle(for: BundleToken.self) - self.init(named: asset.rawValue, in: bundle, compatibleWith: nil) + self.init(named: asset.value, in: bundle, compatibleWith: nil) #elseif os(OSX) || os(watchOS) - self.init(named: asset.rawValue) + self.init(named: asset.value) #endif } } diff --git a/Tests/Expected/Images/swift3-context-defaults.swift b/Tests/Expected/Images/swift3-context-defaults.swift index 1957b20..781c301 100644 --- a/Tests/Expected/Images/swift3-context-defaults.swift +++ b/Tests/Expected/Images/swift3-context-defaults.swift @@ -10,41 +10,63 @@ // swiftlint:disable file_length -// swiftlint:disable identifier_name line_length type_body_length -enum Asset: String { - case exoticBanana = "Exotic/Banana" - case exoticMango = "Exotic/Mango" - case `private` = "private" - case roundApricot = "Round/Apricot" - case roundOrange = "Round/Orange" - case roundApple = "Round/Apple" - case roundDoubleCherry = "Round/Double/Cherry" - case roundTomato = "Round/Tomato" -} -// swiftlint:enable identifier_name line_length type_body_length +struct AssetType: ExpressibleByStringLiteral { + fileprivate var value: String -extension Asset { var image: Image { let bundle = Bundle(for: BundleToken.self) #if os(iOS) || os(tvOS) - let image = Image(named: rawValue, in: bundle, compatibleWith: nil) + let image = Image(named: value, in: bundle, compatibleWith: nil) #elseif os(OSX) - let image = bundle.image(forResource: rawValue) + let image = bundle.image(forResource: value) #elseif os(watchOS) - let image = Image(named: rawValue) + let image = Image(named: value) #endif - guard let result = image else { fatalError("Unable to load image \(rawValue).") } + guard let result = image else { fatalError("Unable to load image \(value).") } return result } + + init(stringLiteral value: String) { + self.value = value + } + + init(extendedGraphemeClusterLiteral value: String) { + self.init(stringLiteral: value) + } + + init(unicodeScalarLiteral value: String) { + self.init(stringLiteral: value) + } +} + +// swiftlint:disable identifier_name line_length nesting type_body_length type_name +enum Asset { + enum Exotic { + static let banana: AssetType = "Exotic/Banana" + static let mango: AssetType = "Exotic/Mango" + } + static let `private`: AssetType = "private" + enum Round { + static let apricot: AssetType = "Round/Apricot" + static let orange: AssetType = "Round/Orange" + enum Red { + static let apple: AssetType = "Round/Apple" + enum Double { + static let cherry: AssetType = "Round/Double/Cherry" + } + static let tomato: AssetType = "Round/Tomato" + } + } } +// swiftlint:enable identifier_name line_length nesting type_body_length type_name extension Image { - convenience init!(asset: Asset) { + convenience init!(asset: AssetType) { #if os(iOS) || os(tvOS) let bundle = Bundle(for: BundleToken.self) - self.init(named: asset.rawValue, in: bundle, compatibleWith: nil) + self.init(named: asset.value, in: bundle, compatibleWith: nil) #elseif os(OSX) || os(watchOS) - self.init(named: asset.rawValue) + self.init(named: asset.value) #endif } } diff --git a/Tests/Expected/Storyboards-iOS/lowercase-context-all-customname.swift b/Tests/Expected/Storyboards-iOS/lowercase-context-all-customname.swift deleted file mode 100644 index c4c8470..0000000 --- a/Tests/Expected/Storyboards-iOS/lowercase-context-all-customname.swift +++ /dev/null @@ -1,188 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// swiftlint:disable sorted_imports -import Foundation -import UIKit -import CustomSegue -import LocationPicker -import SlackTextViewController - -// swiftlint:disable file_length - -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> UIStoryboard { - return UIStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialViewController() -> UIViewController { - guard let vc = storyboard().instantiateInitialViewController() else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func viewController() -> UIViewController { - return Self.storyboard().instantiateViewControllerWithIdentifier(self.rawValue) - } - static func viewController(identifier: Self) -> UIViewController { - return identifier.viewController() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension UIViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -enum XCTStoryboardsScene { - enum AdditionalImport: String, StoryboardSceneType { - static let storyboardName = "AdditionalImport" - - static func initialViewController() -> LocationPicker.LocationPickerViewController { - guard let vc = storyboard().instantiateInitialViewController() as? LocationPicker.LocationPickerViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case `public` - static func publicViewController() -> SlackTextViewController.SLKTextViewController { - guard let vc = XCTStoryboardsScene.AdditionalImport.`public`.viewController() as? SlackTextViewController.SLKTextViewController - else { - fatalError("ViewController 'public' is not of the expected class SlackTextViewController.SLKTextViewController.") - } - return vc - } - } - enum Anonymous: StoryboardSceneType { - static let storyboardName = "Anonymous" - - static func initialViewController() -> UINavigationController { - guard let vc = storyboard().instantiateInitialViewController() as? UINavigationController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - } - enum Dependency: String, StoryboardSceneType { - static let storyboardName = "Dependency" - - case dependent = "Dependent" - static func dependentViewController() -> UIViewController { - return XCTStoryboardsScene.Dependency.dependent.viewController() - } - } - enum Message: String, StoryboardSceneType { - static let storyboardName = "Message" - - case composer = "Composer" - static func composerViewController() -> UIViewController { - return XCTStoryboardsScene.Message.composer.viewController() - } - - case messagesList = "MessagesList" - static func messagesListViewController() -> UITableViewController { - guard let vc = XCTStoryboardsScene.Message.messagesList.viewController() as? UITableViewController - else { - fatalError("ViewController 'MessagesList' is not of the expected class UITableViewController.") - } - return vc - } - - case navCtrl = "NavCtrl" - static func navCtrlViewController() -> UINavigationController { - guard let vc = XCTStoryboardsScene.Message.navCtrl.viewController() as? UINavigationController - else { - fatalError("ViewController 'NavCtrl' is not of the expected class UINavigationController.") - } - return vc - } - - case urlChooser = "URLChooser" - static func urlChooserViewController() -> XXPickerViewController { - guard let vc = XCTStoryboardsScene.Message.urlChooser.viewController() as? XXPickerViewController - else { - fatalError("ViewController 'URLChooser' is not of the expected class XXPickerViewController.") - } - return vc - } - } - enum Placeholder: String, StoryboardSceneType { - static let storyboardName = "Placeholder" - - case navigation = "Navigation" - static func navigationViewController() -> UINavigationController { - guard let vc = XCTStoryboardsScene.Placeholder.navigation.viewController() as? UINavigationController - else { - fatalError("ViewController 'Navigation' is not of the expected class UINavigationController.") - } - return vc - } - } - enum Wizard: String, StoryboardSceneType { - static let storyboardName = "Wizard" - - static func initialViewController() -> CreateAccViewController { - guard let vc = storyboard().instantiateInitialViewController() as? CreateAccViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case accept_CGU = "Accept-CGU" - static func accept_CGUViewController() -> UIViewController { - return XCTStoryboardsScene.Wizard.accept_CGU.viewController() - } - - case createAccount = "CreateAccount" - static func createAccountViewController() -> CreateAccViewController { - guard let vc = XCTStoryboardsScene.Wizard.createAccount.viewController() as? CreateAccViewController - else { - fatalError("ViewController 'CreateAccount' is not of the expected class CreateAccViewController.") - } - return vc - } - - case preferences = "Preferences" - static func preferencesViewController() -> UITableViewController { - guard let vc = XCTStoryboardsScene.Wizard.preferences.viewController() as? UITableViewController - else { - fatalError("ViewController 'Preferences' is not of the expected class UITableViewController.") - } - return vc - } - - case validate_Password = "Validate_Password" - static func validate_PasswordViewController() -> UIViewController { - return XCTStoryboardsScene.Wizard.validate_Password.viewController() - } - } -} - -enum XCTStoryboardsSegue { - enum AdditionalImport: String, StoryboardSegueType { - case Private = "private" - } - enum Message: String, StoryboardSegueType { - case CustomBack - case Embed - case NonCustom - case Show_NavCtrl = "Show-NavCtrl" - } - enum Wizard: String, StoryboardSegueType { - case ShowPassword - } -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} diff --git a/Tests/Expected/Storyboards-iOS/lowercase-context-all-ignore-module.swift b/Tests/Expected/Storyboards-iOS/lowercase-context-all-ignore-module.swift deleted file mode 100644 index 28407f3..0000000 --- a/Tests/Expected/Storyboards-iOS/lowercase-context-all-ignore-module.swift +++ /dev/null @@ -1,187 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// swiftlint:disable sorted_imports -import Foundation -import UIKit -import LocationPicker -import SlackTextViewController - -// swiftlint:disable file_length - -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> UIStoryboard { - return UIStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialViewController() -> UIViewController { - guard let vc = storyboard().instantiateInitialViewController() else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func viewController() -> UIViewController { - return Self.storyboard().instantiateViewControllerWithIdentifier(self.rawValue) - } - static func viewController(identifier: Self) -> UIViewController { - return identifier.viewController() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension UIViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -enum StoryboardScene { - enum AdditionalImport: String, StoryboardSceneType { - static let storyboardName = "AdditionalImport" - - static func initialViewController() -> LocationPicker.LocationPickerViewController { - guard let vc = storyboard().instantiateInitialViewController() as? LocationPicker.LocationPickerViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case `public` - static func publicViewController() -> SlackTextViewController.SLKTextViewController { - guard let vc = StoryboardScene.AdditionalImport.`public`.viewController() as? SlackTextViewController.SLKTextViewController - else { - fatalError("ViewController 'public' is not of the expected class SlackTextViewController.SLKTextViewController.") - } - return vc - } - } - enum Anonymous: StoryboardSceneType { - static let storyboardName = "Anonymous" - - static func initialViewController() -> UINavigationController { - guard let vc = storyboard().instantiateInitialViewController() as? UINavigationController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - } - enum Dependency: String, StoryboardSceneType { - static let storyboardName = "Dependency" - - case dependent = "Dependent" - static func dependentViewController() -> UIViewController { - return StoryboardScene.Dependency.dependent.viewController() - } - } - enum Message: String, StoryboardSceneType { - static let storyboardName = "Message" - - case composer = "Composer" - static func composerViewController() -> UIViewController { - return StoryboardScene.Message.composer.viewController() - } - - case messagesList = "MessagesList" - static func messagesListViewController() -> UITableViewController { - guard let vc = StoryboardScene.Message.messagesList.viewController() as? UITableViewController - else { - fatalError("ViewController 'MessagesList' is not of the expected class UITableViewController.") - } - return vc - } - - case navCtrl = "NavCtrl" - static func navCtrlViewController() -> UINavigationController { - guard let vc = StoryboardScene.Message.navCtrl.viewController() as? UINavigationController - else { - fatalError("ViewController 'NavCtrl' is not of the expected class UINavigationController.") - } - return vc - } - - case urlChooser = "URLChooser" - static func urlChooserViewController() -> XXPickerViewController { - guard let vc = StoryboardScene.Message.urlChooser.viewController() as? XXPickerViewController - else { - fatalError("ViewController 'URLChooser' is not of the expected class XXPickerViewController.") - } - return vc - } - } - enum Placeholder: String, StoryboardSceneType { - static let storyboardName = "Placeholder" - - case navigation = "Navigation" - static func navigationViewController() -> UINavigationController { - guard let vc = StoryboardScene.Placeholder.navigation.viewController() as? UINavigationController - else { - fatalError("ViewController 'Navigation' is not of the expected class UINavigationController.") - } - return vc - } - } - enum Wizard: String, StoryboardSceneType { - static let storyboardName = "Wizard" - - static func initialViewController() -> CreateAccViewController { - guard let vc = storyboard().instantiateInitialViewController() as? CreateAccViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case accept_CGU = "Accept-CGU" - static func accept_CGUViewController() -> UIViewController { - return StoryboardScene.Wizard.accept_CGU.viewController() - } - - case createAccount = "CreateAccount" - static func createAccountViewController() -> CreateAccViewController { - guard let vc = StoryboardScene.Wizard.createAccount.viewController() as? CreateAccViewController - else { - fatalError("ViewController 'CreateAccount' is not of the expected class CreateAccViewController.") - } - return vc - } - - case preferences = "Preferences" - static func preferencesViewController() -> UITableViewController { - guard let vc = StoryboardScene.Wizard.preferences.viewController() as? UITableViewController - else { - fatalError("ViewController 'Preferences' is not of the expected class UITableViewController.") - } - return vc - } - - case validate_Password = "Validate_Password" - static func validate_PasswordViewController() -> UIViewController { - return StoryboardScene.Wizard.validate_Password.viewController() - } - } -} - -enum StoryboardSegue { - enum AdditionalImport: String, StoryboardSegueType { - case Private = "private" - } - enum Message: String, StoryboardSegueType { - case CustomBack - case Embed - case NonCustom - case Show_NavCtrl = "Show-NavCtrl" - } - enum Wizard: String, StoryboardSegueType { - case ShowPassword - } -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} diff --git a/Tests/Expected/Storyboards-iOS/lowercase-context-all.swift b/Tests/Expected/Storyboards-iOS/lowercase-context-all.swift deleted file mode 100644 index bc74f54..0000000 --- a/Tests/Expected/Storyboards-iOS/lowercase-context-all.swift +++ /dev/null @@ -1,188 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// swiftlint:disable sorted_imports -import Foundation -import UIKit -import CustomSegue -import LocationPicker -import SlackTextViewController - -// swiftlint:disable file_length - -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> UIStoryboard { - return UIStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialViewController() -> UIViewController { - guard let vc = storyboard().instantiateInitialViewController() else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func viewController() -> UIViewController { - return Self.storyboard().instantiateViewControllerWithIdentifier(self.rawValue) - } - static func viewController(identifier: Self) -> UIViewController { - return identifier.viewController() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension UIViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -enum StoryboardScene { - enum AdditionalImport: String, StoryboardSceneType { - static let storyboardName = "AdditionalImport" - - static func initialViewController() -> LocationPicker.LocationPickerViewController { - guard let vc = storyboard().instantiateInitialViewController() as? LocationPicker.LocationPickerViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case `public` - static func publicViewController() -> SlackTextViewController.SLKTextViewController { - guard let vc = StoryboardScene.AdditionalImport.`public`.viewController() as? SlackTextViewController.SLKTextViewController - else { - fatalError("ViewController 'public' is not of the expected class SlackTextViewController.SLKTextViewController.") - } - return vc - } - } - enum Anonymous: StoryboardSceneType { - static let storyboardName = "Anonymous" - - static func initialViewController() -> UINavigationController { - guard let vc = storyboard().instantiateInitialViewController() as? UINavigationController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - } - enum Dependency: String, StoryboardSceneType { - static let storyboardName = "Dependency" - - case dependent = "Dependent" - static func dependentViewController() -> UIViewController { - return StoryboardScene.Dependency.dependent.viewController() - } - } - enum Message: String, StoryboardSceneType { - static let storyboardName = "Message" - - case composer = "Composer" - static func composerViewController() -> UIViewController { - return StoryboardScene.Message.composer.viewController() - } - - case messagesList = "MessagesList" - static func messagesListViewController() -> UITableViewController { - guard let vc = StoryboardScene.Message.messagesList.viewController() as? UITableViewController - else { - fatalError("ViewController 'MessagesList' is not of the expected class UITableViewController.") - } - return vc - } - - case navCtrl = "NavCtrl" - static func navCtrlViewController() -> UINavigationController { - guard let vc = StoryboardScene.Message.navCtrl.viewController() as? UINavigationController - else { - fatalError("ViewController 'NavCtrl' is not of the expected class UINavigationController.") - } - return vc - } - - case urlChooser = "URLChooser" - static func urlChooserViewController() -> XXPickerViewController { - guard let vc = StoryboardScene.Message.urlChooser.viewController() as? XXPickerViewController - else { - fatalError("ViewController 'URLChooser' is not of the expected class XXPickerViewController.") - } - return vc - } - } - enum Placeholder: String, StoryboardSceneType { - static let storyboardName = "Placeholder" - - case navigation = "Navigation" - static func navigationViewController() -> UINavigationController { - guard let vc = StoryboardScene.Placeholder.navigation.viewController() as? UINavigationController - else { - fatalError("ViewController 'Navigation' is not of the expected class UINavigationController.") - } - return vc - } - } - enum Wizard: String, StoryboardSceneType { - static let storyboardName = "Wizard" - - static func initialViewController() -> CreateAccViewController { - guard let vc = storyboard().instantiateInitialViewController() as? CreateAccViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case accept_CGU = "Accept-CGU" - static func accept_CGUViewController() -> UIViewController { - return StoryboardScene.Wizard.accept_CGU.viewController() - } - - case createAccount = "CreateAccount" - static func createAccountViewController() -> CreateAccViewController { - guard let vc = StoryboardScene.Wizard.createAccount.viewController() as? CreateAccViewController - else { - fatalError("ViewController 'CreateAccount' is not of the expected class CreateAccViewController.") - } - return vc - } - - case preferences = "Preferences" - static func preferencesViewController() -> UITableViewController { - guard let vc = StoryboardScene.Wizard.preferences.viewController() as? UITableViewController - else { - fatalError("ViewController 'Preferences' is not of the expected class UITableViewController.") - } - return vc - } - - case validate_Password = "Validate_Password" - static func validate_PasswordViewController() -> UIViewController { - return StoryboardScene.Wizard.validate_Password.viewController() - } - } -} - -enum StoryboardSegue { - enum AdditionalImport: String, StoryboardSegueType { - case Private = "private" - } - enum Message: String, StoryboardSegueType { - case CustomBack - case Embed - case NonCustom - case Show_NavCtrl = "Show-NavCtrl" - } - enum Wizard: String, StoryboardSegueType { - case ShowPassword - } -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} diff --git a/Tests/Expected/Storyboards-iOS/default-context-all-customname.swift b/Tests/Expected/Storyboards-iOS/swift2-context-all-customname.swift similarity index 100% rename from Tests/Expected/Storyboards-iOS/default-context-all-customname.swift rename to Tests/Expected/Storyboards-iOS/swift2-context-all-customname.swift diff --git a/Tests/Expected/Storyboards-iOS/default-context-all-ignore-module.swift b/Tests/Expected/Storyboards-iOS/swift2-context-all-ignore-module.swift similarity index 100% rename from Tests/Expected/Storyboards-iOS/default-context-all-ignore-module.swift rename to Tests/Expected/Storyboards-iOS/swift2-context-all-ignore-module.swift diff --git a/Tests/Expected/Storyboards-iOS/default-context-all.swift b/Tests/Expected/Storyboards-iOS/swift2-context-all.swift similarity index 100% rename from Tests/Expected/Storyboards-iOS/default-context-all.swift rename to Tests/Expected/Storyboards-iOS/swift2-context-all.swift diff --git a/Tests/Expected/Storyboards-iOS/default-context-empty.swift b/Tests/Expected/Storyboards-iOS/swift2-context-empty.swift similarity index 100% rename from Tests/Expected/Storyboards-iOS/default-context-empty.swift rename to Tests/Expected/Storyboards-iOS/swift2-context-empty.swift diff --git a/Tests/Expected/Storyboards-iOS/uppercase-context-all-customname.swift b/Tests/Expected/Storyboards-iOS/uppercase-context-all-customname.swift deleted file mode 100644 index 9d47940..0000000 --- a/Tests/Expected/Storyboards-iOS/uppercase-context-all-customname.swift +++ /dev/null @@ -1,188 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// swiftlint:disable sorted_imports -import Foundation -import UIKit -import CustomSegue -import LocationPicker -import SlackTextViewController - -// swiftlint:disable file_length - -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> UIStoryboard { - return UIStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialViewController() -> UIViewController { - guard let vc = storyboard().instantiateInitialViewController() else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func viewController() -> UIViewController { - return Self.storyboard().instantiateViewControllerWithIdentifier(self.rawValue) - } - static func viewController(identifier: Self) -> UIViewController { - return identifier.viewController() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension UIViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -enum XCTStoryboardsScene { - enum AdditionalImport: String, StoryboardSceneType { - static let storyboardName = "AdditionalImport" - - static func initialViewController() -> LocationPicker.LocationPickerViewController { - guard let vc = storyboard().instantiateInitialViewController() as? LocationPicker.LocationPickerViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case Public = "public" - static func publicViewController() -> SlackTextViewController.SLKTextViewController { - guard let vc = XCTStoryboardsScene.AdditionalImport.Public.viewController() as? SlackTextViewController.SLKTextViewController - else { - fatalError("ViewController 'public' is not of the expected class SlackTextViewController.SLKTextViewController.") - } - return vc - } - } - enum Anonymous: StoryboardSceneType { - static let storyboardName = "Anonymous" - - static func initialViewController() -> UINavigationController { - guard let vc = storyboard().instantiateInitialViewController() as? UINavigationController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - } - enum Dependency: String, StoryboardSceneType { - static let storyboardName = "Dependency" - - case Dependent - static func dependentViewController() -> UIViewController { - return XCTStoryboardsScene.Dependency.Dependent.viewController() - } - } - enum Message: String, StoryboardSceneType { - static let storyboardName = "Message" - - case Composer - static func composerViewController() -> UIViewController { - return XCTStoryboardsScene.Message.Composer.viewController() - } - - case MessagesList - static func messagesListViewController() -> UITableViewController { - guard let vc = XCTStoryboardsScene.Message.MessagesList.viewController() as? UITableViewController - else { - fatalError("ViewController 'MessagesList' is not of the expected class UITableViewController.") - } - return vc - } - - case NavCtrl - static func navCtrlViewController() -> UINavigationController { - guard let vc = XCTStoryboardsScene.Message.NavCtrl.viewController() as? UINavigationController - else { - fatalError("ViewController 'NavCtrl' is not of the expected class UINavigationController.") - } - return vc - } - - case URLChooser - static func urlChooserViewController() -> XXPickerViewController { - guard let vc = XCTStoryboardsScene.Message.URLChooser.viewController() as? XXPickerViewController - else { - fatalError("ViewController 'URLChooser' is not of the expected class XXPickerViewController.") - } - return vc - } - } - enum Placeholder: String, StoryboardSceneType { - static let storyboardName = "Placeholder" - - case Navigation - static func navigationViewController() -> UINavigationController { - guard let vc = XCTStoryboardsScene.Placeholder.Navigation.viewController() as? UINavigationController - else { - fatalError("ViewController 'Navigation' is not of the expected class UINavigationController.") - } - return vc - } - } - enum Wizard: String, StoryboardSceneType { - static let storyboardName = "Wizard" - - static func initialViewController() -> CreateAccViewController { - guard let vc = storyboard().instantiateInitialViewController() as? CreateAccViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case Accept_CGU = "Accept-CGU" - static func acceptCGUViewController() -> UIViewController { - return XCTStoryboardsScene.Wizard.Accept_CGU.viewController() - } - - case CreateAccount - static func createAccountViewController() -> CreateAccViewController { - guard let vc = XCTStoryboardsScene.Wizard.CreateAccount.viewController() as? CreateAccViewController - else { - fatalError("ViewController 'CreateAccount' is not of the expected class CreateAccViewController.") - } - return vc - } - - case Preferences - static func preferencesViewController() -> UITableViewController { - guard let vc = XCTStoryboardsScene.Wizard.Preferences.viewController() as? UITableViewController - else { - fatalError("ViewController 'Preferences' is not of the expected class UITableViewController.") - } - return vc - } - - case Validate_Password - static func validatePasswordViewController() -> UIViewController { - return XCTStoryboardsScene.Wizard.Validate_Password.viewController() - } - } -} - -enum XCTStoryboardsSegue { - enum AdditionalImport: String, StoryboardSegueType { - case Private = "private" - } - enum Message: String, StoryboardSegueType { - case CustomBack - case Embed - case NonCustom - case Show_NavCtrl = "Show-NavCtrl" - } - enum Wizard: String, StoryboardSegueType { - case ShowPassword - } -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} diff --git a/Tests/Expected/Storyboards-iOS/uppercase-context-all-ignore-module.swift b/Tests/Expected/Storyboards-iOS/uppercase-context-all-ignore-module.swift deleted file mode 100644 index 0ac8c38..0000000 --- a/Tests/Expected/Storyboards-iOS/uppercase-context-all-ignore-module.swift +++ /dev/null @@ -1,187 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// swiftlint:disable sorted_imports -import Foundation -import UIKit -import LocationPicker -import SlackTextViewController - -// swiftlint:disable file_length - -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> UIStoryboard { - return UIStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialViewController() -> UIViewController { - guard let vc = storyboard().instantiateInitialViewController() else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func viewController() -> UIViewController { - return Self.storyboard().instantiateViewControllerWithIdentifier(self.rawValue) - } - static func viewController(identifier: Self) -> UIViewController { - return identifier.viewController() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension UIViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -enum StoryboardScene { - enum AdditionalImport: String, StoryboardSceneType { - static let storyboardName = "AdditionalImport" - - static func initialViewController() -> LocationPicker.LocationPickerViewController { - guard let vc = storyboard().instantiateInitialViewController() as? LocationPicker.LocationPickerViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case Public = "public" - static func publicViewController() -> SlackTextViewController.SLKTextViewController { - guard let vc = StoryboardScene.AdditionalImport.Public.viewController() as? SlackTextViewController.SLKTextViewController - else { - fatalError("ViewController 'public' is not of the expected class SlackTextViewController.SLKTextViewController.") - } - return vc - } - } - enum Anonymous: StoryboardSceneType { - static let storyboardName = "Anonymous" - - static func initialViewController() -> UINavigationController { - guard let vc = storyboard().instantiateInitialViewController() as? UINavigationController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - } - enum Dependency: String, StoryboardSceneType { - static let storyboardName = "Dependency" - - case Dependent - static func dependentViewController() -> UIViewController { - return StoryboardScene.Dependency.Dependent.viewController() - } - } - enum Message: String, StoryboardSceneType { - static let storyboardName = "Message" - - case Composer - static func composerViewController() -> UIViewController { - return StoryboardScene.Message.Composer.viewController() - } - - case MessagesList - static func messagesListViewController() -> UITableViewController { - guard let vc = StoryboardScene.Message.MessagesList.viewController() as? UITableViewController - else { - fatalError("ViewController 'MessagesList' is not of the expected class UITableViewController.") - } - return vc - } - - case NavCtrl - static func navCtrlViewController() -> UINavigationController { - guard let vc = StoryboardScene.Message.NavCtrl.viewController() as? UINavigationController - else { - fatalError("ViewController 'NavCtrl' is not of the expected class UINavigationController.") - } - return vc - } - - case URLChooser - static func urlChooserViewController() -> XXPickerViewController { - guard let vc = StoryboardScene.Message.URLChooser.viewController() as? XXPickerViewController - else { - fatalError("ViewController 'URLChooser' is not of the expected class XXPickerViewController.") - } - return vc - } - } - enum Placeholder: String, StoryboardSceneType { - static let storyboardName = "Placeholder" - - case Navigation - static func navigationViewController() -> UINavigationController { - guard let vc = StoryboardScene.Placeholder.Navigation.viewController() as? UINavigationController - else { - fatalError("ViewController 'Navigation' is not of the expected class UINavigationController.") - } - return vc - } - } - enum Wizard: String, StoryboardSceneType { - static let storyboardName = "Wizard" - - static func initialViewController() -> CreateAccViewController { - guard let vc = storyboard().instantiateInitialViewController() as? CreateAccViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case Accept_CGU = "Accept-CGU" - static func acceptCGUViewController() -> UIViewController { - return StoryboardScene.Wizard.Accept_CGU.viewController() - } - - case CreateAccount - static func createAccountViewController() -> CreateAccViewController { - guard let vc = StoryboardScene.Wizard.CreateAccount.viewController() as? CreateAccViewController - else { - fatalError("ViewController 'CreateAccount' is not of the expected class CreateAccViewController.") - } - return vc - } - - case Preferences - static func preferencesViewController() -> UITableViewController { - guard let vc = StoryboardScene.Wizard.Preferences.viewController() as? UITableViewController - else { - fatalError("ViewController 'Preferences' is not of the expected class UITableViewController.") - } - return vc - } - - case Validate_Password - static func validatePasswordViewController() -> UIViewController { - return StoryboardScene.Wizard.Validate_Password.viewController() - } - } -} - -enum StoryboardSegue { - enum AdditionalImport: String, StoryboardSegueType { - case Private = "private" - } - enum Message: String, StoryboardSegueType { - case CustomBack - case Embed - case NonCustom - case Show_NavCtrl = "Show-NavCtrl" - } - enum Wizard: String, StoryboardSegueType { - case ShowPassword - } -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} diff --git a/Tests/Expected/Storyboards-iOS/uppercase-context-all.swift b/Tests/Expected/Storyboards-iOS/uppercase-context-all.swift deleted file mode 100644 index e6a483a..0000000 --- a/Tests/Expected/Storyboards-iOS/uppercase-context-all.swift +++ /dev/null @@ -1,188 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// swiftlint:disable sorted_imports -import Foundation -import UIKit -import CustomSegue -import LocationPicker -import SlackTextViewController - -// swiftlint:disable file_length - -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> UIStoryboard { - return UIStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialViewController() -> UIViewController { - guard let vc = storyboard().instantiateInitialViewController() else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func viewController() -> UIViewController { - return Self.storyboard().instantiateViewControllerWithIdentifier(self.rawValue) - } - static func viewController(identifier: Self) -> UIViewController { - return identifier.viewController() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension UIViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -enum StoryboardScene { - enum AdditionalImport: String, StoryboardSceneType { - static let storyboardName = "AdditionalImport" - - static func initialViewController() -> LocationPicker.LocationPickerViewController { - guard let vc = storyboard().instantiateInitialViewController() as? LocationPicker.LocationPickerViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case Public = "public" - static func publicViewController() -> SlackTextViewController.SLKTextViewController { - guard let vc = StoryboardScene.AdditionalImport.Public.viewController() as? SlackTextViewController.SLKTextViewController - else { - fatalError("ViewController 'public' is not of the expected class SlackTextViewController.SLKTextViewController.") - } - return vc - } - } - enum Anonymous: StoryboardSceneType { - static let storyboardName = "Anonymous" - - static func initialViewController() -> UINavigationController { - guard let vc = storyboard().instantiateInitialViewController() as? UINavigationController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - } - enum Dependency: String, StoryboardSceneType { - static let storyboardName = "Dependency" - - case Dependent - static func dependentViewController() -> UIViewController { - return StoryboardScene.Dependency.Dependent.viewController() - } - } - enum Message: String, StoryboardSceneType { - static let storyboardName = "Message" - - case Composer - static func composerViewController() -> UIViewController { - return StoryboardScene.Message.Composer.viewController() - } - - case MessagesList - static func messagesListViewController() -> UITableViewController { - guard let vc = StoryboardScene.Message.MessagesList.viewController() as? UITableViewController - else { - fatalError("ViewController 'MessagesList' is not of the expected class UITableViewController.") - } - return vc - } - - case NavCtrl - static func navCtrlViewController() -> UINavigationController { - guard let vc = StoryboardScene.Message.NavCtrl.viewController() as? UINavigationController - else { - fatalError("ViewController 'NavCtrl' is not of the expected class UINavigationController.") - } - return vc - } - - case URLChooser - static func urlChooserViewController() -> XXPickerViewController { - guard let vc = StoryboardScene.Message.URLChooser.viewController() as? XXPickerViewController - else { - fatalError("ViewController 'URLChooser' is not of the expected class XXPickerViewController.") - } - return vc - } - } - enum Placeholder: String, StoryboardSceneType { - static let storyboardName = "Placeholder" - - case Navigation - static func navigationViewController() -> UINavigationController { - guard let vc = StoryboardScene.Placeholder.Navigation.viewController() as? UINavigationController - else { - fatalError("ViewController 'Navigation' is not of the expected class UINavigationController.") - } - return vc - } - } - enum Wizard: String, StoryboardSceneType { - static let storyboardName = "Wizard" - - static func initialViewController() -> CreateAccViewController { - guard let vc = storyboard().instantiateInitialViewController() as? CreateAccViewController else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return vc - } - - case Accept_CGU = "Accept-CGU" - static func acceptCGUViewController() -> UIViewController { - return StoryboardScene.Wizard.Accept_CGU.viewController() - } - - case CreateAccount - static func createAccountViewController() -> CreateAccViewController { - guard let vc = StoryboardScene.Wizard.CreateAccount.viewController() as? CreateAccViewController - else { - fatalError("ViewController 'CreateAccount' is not of the expected class CreateAccViewController.") - } - return vc - } - - case Preferences - static func preferencesViewController() -> UITableViewController { - guard let vc = StoryboardScene.Wizard.Preferences.viewController() as? UITableViewController - else { - fatalError("ViewController 'Preferences' is not of the expected class UITableViewController.") - } - return vc - } - - case Validate_Password - static func validatePasswordViewController() -> UIViewController { - return StoryboardScene.Wizard.Validate_Password.viewController() - } - } -} - -enum StoryboardSegue { - enum AdditionalImport: String, StoryboardSegueType { - case Private = "private" - } - enum Message: String, StoryboardSegueType { - case CustomBack - case Embed - case NonCustom - case Show_NavCtrl = "Show-NavCtrl" - } - enum Wizard: String, StoryboardSegueType { - case ShowPassword - } -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} diff --git a/Tests/Expected/Storyboards-iOS/uppercase-context-empty.swift b/Tests/Expected/Storyboards-iOS/uppercase-context-empty.swift deleted file mode 100644 index 55455a6..0000000 --- a/Tests/Expected/Storyboards-iOS/uppercase-context-empty.swift +++ /dev/null @@ -1,3 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// No storyboard found diff --git a/Tests/Expected/Storyboards-macOS/default-context-empty.swift b/Tests/Expected/Storyboards-macOS/default-context-empty.swift deleted file mode 100644 index 55455a6..0000000 --- a/Tests/Expected/Storyboards-macOS/default-context-empty.swift +++ /dev/null @@ -1,3 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// No storyboard found diff --git a/Tests/Expected/Storyboards-macOS/lowercase-context-all-customname.swift b/Tests/Expected/Storyboards-macOS/lowercase-context-all-customname.swift deleted file mode 100644 index a609c0d..0000000 --- a/Tests/Expected/Storyboards-macOS/lowercase-context-all-customname.swift +++ /dev/null @@ -1,173 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// swiftlint:disable sorted_imports -import Cocoa -import Foundation -import FadeSegue -import PrefsWindowController - -// swiftlint:disable file_length - -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> NSStoryboard { - return NSStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialController() -> AnyObject { - guard let controller = storyboard().instantiateInitialController() - else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return controller - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func controller() -> AnyObject { - return Self.storyboard().instantiateControllerWithIdentifier(self.rawValue) - } - static func controller(identifier: Self) -> AnyObject { - return identifier.controller() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension NSWindowController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -extension NSViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -enum XCTStoryboardsScene { - enum AdditionalImport: String, StoryboardSceneType { - static let storyboardName = "AdditionalImport" - - case privateScene = "private" - static func instantiatePrivate() -> PrefsWindowController.DBPrefsWindowController { - guard let vc = XCTStoryboardsScene.AdditionalImport.privateScene.controller() as? PrefsWindowController.DBPrefsWindowController - else { - fatalError("ViewController 'private' is not of the expected class PrefsWindowController.DBPrefsWindowController.") - } - return vc - } - } - enum Anonymous: StoryboardSceneType { - static let storyboardName = "Anonymous" - } - enum Dependency: String, StoryboardSceneType { - static let storyboardName = "Dependency" - - case dependentScene = "Dependent" - static func instantiateDependent() -> NSViewController { - guard let vc = XCTStoryboardsScene.Dependency.dependentScene.controller() as? NSViewController - else { - fatalError("ViewController 'Dependent' is not of the expected class NSViewController.") - } - return vc - } - } - enum Message: String, StoryboardSceneType { - static let storyboardName = "Message" - - case messageDetailsScene = "MessageDetails" - static func instantiateMessageDetails() -> NSViewController { - guard let vc = XCTStoryboardsScene.Message.messageDetailsScene.controller() as? NSViewController - else { - fatalError("ViewController 'MessageDetails' is not of the expected class NSViewController.") - } - return vc - } - - case messageListScene = "MessageList" - static func instantiateMessageList() -> NSViewController { - guard let vc = XCTStoryboardsScene.Message.messageListScene.controller() as? NSViewController - else { - fatalError("ViewController 'MessageList' is not of the expected class NSViewController.") - } - return vc - } - - case messageListFooterScene = "MessageListFooter" - static func instantiateMessageListFooter() -> NSViewController { - guard let vc = XCTStoryboardsScene.Message.messageListFooterScene.controller() as? NSViewController - else { - fatalError("ViewController 'MessageListFooter' is not of the expected class NSViewController.") - } - return vc - } - - case messagesTabScene = "MessagesTab" - static func instantiateMessagesTab() -> CustomTabViewController { - guard let vc = XCTStoryboardsScene.Message.messagesTabScene.controller() as? CustomTabViewController - else { - fatalError("ViewController 'MessagesTab' is not of the expected class CustomTabViewController.") - } - return vc - } - - case splitMessagesScene = "SplitMessages" - static func instantiateSplitMessages() -> NSSplitViewController { - guard let vc = XCTStoryboardsScene.Message.splitMessagesScene.controller() as? NSSplitViewController - else { - fatalError("ViewController 'SplitMessages' is not of the expected class NSSplitViewController.") - } - return vc - } - - case windowCtrlScene = "WindowCtrl" - static func instantiateWindowCtrl() -> NSWindowController { - guard let vc = XCTStoryboardsScene.Message.windowCtrlScene.controller() as? NSWindowController - else { - fatalError("ViewController 'WindowCtrl' is not of the expected class NSWindowController.") - } - return vc - } - } - enum Placeholder: String, StoryboardSceneType { - static let storyboardName = "Placeholder" - - case dependentScene = "Dependent" - static func instantiateDependent() -> NSControllerPlaceholder { - guard let vc = XCTStoryboardsScene.Placeholder.dependentScene.controller() as? NSControllerPlaceholder - else { - fatalError("ViewController 'Dependent' is not of the expected class NSControllerPlaceholder.") - } - return vc - } - - case windowScene = "Window" - static func instantiateWindow() -> NSWindowController { - guard let vc = XCTStoryboardsScene.Placeholder.windowScene.controller() as? NSWindowController - else { - fatalError("ViewController 'Window' is not of the expected class NSWindowController.") - } - return vc - } - } -} - -enum XCTStoryboardsSegue { - enum Message: String, StoryboardSegueType { - case Embed - case Modal - case Popover - case Sheet - case Show - case Public = "public" - } -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} diff --git a/Tests/Expected/Storyboards-macOS/lowercase-context-all-ignore-module.swift b/Tests/Expected/Storyboards-macOS/lowercase-context-all-ignore-module.swift deleted file mode 100644 index f96ed3a..0000000 --- a/Tests/Expected/Storyboards-macOS/lowercase-context-all-ignore-module.swift +++ /dev/null @@ -1,172 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// swiftlint:disable sorted_imports -import Cocoa -import Foundation -import PrefsWindowController - -// swiftlint:disable file_length - -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> NSStoryboard { - return NSStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialController() -> AnyObject { - guard let controller = storyboard().instantiateInitialController() - else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return controller - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func controller() -> AnyObject { - return Self.storyboard().instantiateControllerWithIdentifier(self.rawValue) - } - static func controller(identifier: Self) -> AnyObject { - return identifier.controller() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension NSWindowController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -extension NSViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -enum StoryboardScene { - enum AdditionalImport: String, StoryboardSceneType { - static let storyboardName = "AdditionalImport" - - case privateScene = "private" - static func instantiatePrivate() -> PrefsWindowController.DBPrefsWindowController { - guard let vc = StoryboardScene.AdditionalImport.privateScene.controller() as? PrefsWindowController.DBPrefsWindowController - else { - fatalError("ViewController 'private' is not of the expected class PrefsWindowController.DBPrefsWindowController.") - } - return vc - } - } - enum Anonymous: StoryboardSceneType { - static let storyboardName = "Anonymous" - } - enum Dependency: String, StoryboardSceneType { - static let storyboardName = "Dependency" - - case dependentScene = "Dependent" - static func instantiateDependent() -> NSViewController { - guard let vc = StoryboardScene.Dependency.dependentScene.controller() as? NSViewController - else { - fatalError("ViewController 'Dependent' is not of the expected class NSViewController.") - } - return vc - } - } - enum Message: String, StoryboardSceneType { - static let storyboardName = "Message" - - case messageDetailsScene = "MessageDetails" - static func instantiateMessageDetails() -> NSViewController { - guard let vc = StoryboardScene.Message.messageDetailsScene.controller() as? NSViewController - else { - fatalError("ViewController 'MessageDetails' is not of the expected class NSViewController.") - } - return vc - } - - case messageListScene = "MessageList" - static func instantiateMessageList() -> NSViewController { - guard let vc = StoryboardScene.Message.messageListScene.controller() as? NSViewController - else { - fatalError("ViewController 'MessageList' is not of the expected class NSViewController.") - } - return vc - } - - case messageListFooterScene = "MessageListFooter" - static func instantiateMessageListFooter() -> NSViewController { - guard let vc = StoryboardScene.Message.messageListFooterScene.controller() as? NSViewController - else { - fatalError("ViewController 'MessageListFooter' is not of the expected class NSViewController.") - } - return vc - } - - case messagesTabScene = "MessagesTab" - static func instantiateMessagesTab() -> CustomTabViewController { - guard let vc = StoryboardScene.Message.messagesTabScene.controller() as? CustomTabViewController - else { - fatalError("ViewController 'MessagesTab' is not of the expected class CustomTabViewController.") - } - return vc - } - - case splitMessagesScene = "SplitMessages" - static func instantiateSplitMessages() -> NSSplitViewController { - guard let vc = StoryboardScene.Message.splitMessagesScene.controller() as? NSSplitViewController - else { - fatalError("ViewController 'SplitMessages' is not of the expected class NSSplitViewController.") - } - return vc - } - - case windowCtrlScene = "WindowCtrl" - static func instantiateWindowCtrl() -> NSWindowController { - guard let vc = StoryboardScene.Message.windowCtrlScene.controller() as? NSWindowController - else { - fatalError("ViewController 'WindowCtrl' is not of the expected class NSWindowController.") - } - return vc - } - } - enum Placeholder: String, StoryboardSceneType { - static let storyboardName = "Placeholder" - - case dependentScene = "Dependent" - static func instantiateDependent() -> NSControllerPlaceholder { - guard let vc = StoryboardScene.Placeholder.dependentScene.controller() as? NSControllerPlaceholder - else { - fatalError("ViewController 'Dependent' is not of the expected class NSControllerPlaceholder.") - } - return vc - } - - case windowScene = "Window" - static func instantiateWindow() -> NSWindowController { - guard let vc = StoryboardScene.Placeholder.windowScene.controller() as? NSWindowController - else { - fatalError("ViewController 'Window' is not of the expected class NSWindowController.") - } - return vc - } - } -} - -enum StoryboardSegue { - enum Message: String, StoryboardSegueType { - case Embed - case Modal - case Popover - case Sheet - case Show - case Public = "public" - } -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} diff --git a/Tests/Expected/Storyboards-macOS/lowercase-context-all.swift b/Tests/Expected/Storyboards-macOS/lowercase-context-all.swift deleted file mode 100644 index 5bf3346..0000000 --- a/Tests/Expected/Storyboards-macOS/lowercase-context-all.swift +++ /dev/null @@ -1,173 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// swiftlint:disable sorted_imports -import Cocoa -import Foundation -import FadeSegue -import PrefsWindowController - -// swiftlint:disable file_length - -protocol StoryboardSceneType { - static var storyboardName: String { get } -} - -extension StoryboardSceneType { - static func storyboard() -> NSStoryboard { - return NSStoryboard(name: self.storyboardName, bundle: NSBundle(forClass: BundleToken.self)) - } - - static func initialController() -> AnyObject { - guard let controller = storyboard().instantiateInitialController() - else { - fatalError("Failed to instantiate initialViewController for \(self.storyboardName)") - } - return controller - } -} - -extension StoryboardSceneType where Self: RawRepresentable, Self.RawValue == String { - func controller() -> AnyObject { - return Self.storyboard().instantiateControllerWithIdentifier(self.rawValue) - } - static func controller(identifier: Self) -> AnyObject { - return identifier.controller() - } -} - -protocol StoryboardSegueType: RawRepresentable { } - -extension NSWindowController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -extension NSViewController { - func performSegue(segue: S, sender: AnyObject? = nil) { - performSegueWithIdentifier(segue.rawValue, sender: sender) - } -} - -// swiftlint:disable explicit_type_interface identifier_name line_length type_body_length type_name -enum StoryboardScene { - enum AdditionalImport: String, StoryboardSceneType { - static let storyboardName = "AdditionalImport" - - case privateScene = "private" - static func instantiatePrivate() -> PrefsWindowController.DBPrefsWindowController { - guard let vc = StoryboardScene.AdditionalImport.privateScene.controller() as? PrefsWindowController.DBPrefsWindowController - else { - fatalError("ViewController 'private' is not of the expected class PrefsWindowController.DBPrefsWindowController.") - } - return vc - } - } - enum Anonymous: StoryboardSceneType { - static let storyboardName = "Anonymous" - } - enum Dependency: String, StoryboardSceneType { - static let storyboardName = "Dependency" - - case dependentScene = "Dependent" - static func instantiateDependent() -> NSViewController { - guard let vc = StoryboardScene.Dependency.dependentScene.controller() as? NSViewController - else { - fatalError("ViewController 'Dependent' is not of the expected class NSViewController.") - } - return vc - } - } - enum Message: String, StoryboardSceneType { - static let storyboardName = "Message" - - case messageDetailsScene = "MessageDetails" - static func instantiateMessageDetails() -> NSViewController { - guard let vc = StoryboardScene.Message.messageDetailsScene.controller() as? NSViewController - else { - fatalError("ViewController 'MessageDetails' is not of the expected class NSViewController.") - } - return vc - } - - case messageListScene = "MessageList" - static func instantiateMessageList() -> NSViewController { - guard let vc = StoryboardScene.Message.messageListScene.controller() as? NSViewController - else { - fatalError("ViewController 'MessageList' is not of the expected class NSViewController.") - } - return vc - } - - case messageListFooterScene = "MessageListFooter" - static func instantiateMessageListFooter() -> NSViewController { - guard let vc = StoryboardScene.Message.messageListFooterScene.controller() as? NSViewController - else { - fatalError("ViewController 'MessageListFooter' is not of the expected class NSViewController.") - } - return vc - } - - case messagesTabScene = "MessagesTab" - static func instantiateMessagesTab() -> CustomTabViewController { - guard let vc = StoryboardScene.Message.messagesTabScene.controller() as? CustomTabViewController - else { - fatalError("ViewController 'MessagesTab' is not of the expected class CustomTabViewController.") - } - return vc - } - - case splitMessagesScene = "SplitMessages" - static func instantiateSplitMessages() -> NSSplitViewController { - guard let vc = StoryboardScene.Message.splitMessagesScene.controller() as? NSSplitViewController - else { - fatalError("ViewController 'SplitMessages' is not of the expected class NSSplitViewController.") - } - return vc - } - - case windowCtrlScene = "WindowCtrl" - static func instantiateWindowCtrl() -> NSWindowController { - guard let vc = StoryboardScene.Message.windowCtrlScene.controller() as? NSWindowController - else { - fatalError("ViewController 'WindowCtrl' is not of the expected class NSWindowController.") - } - return vc - } - } - enum Placeholder: String, StoryboardSceneType { - static let storyboardName = "Placeholder" - - case dependentScene = "Dependent" - static func instantiateDependent() -> NSControllerPlaceholder { - guard let vc = StoryboardScene.Placeholder.dependentScene.controller() as? NSControllerPlaceholder - else { - fatalError("ViewController 'Dependent' is not of the expected class NSControllerPlaceholder.") - } - return vc - } - - case windowScene = "Window" - static func instantiateWindow() -> NSWindowController { - guard let vc = StoryboardScene.Placeholder.windowScene.controller() as? NSWindowController - else { - fatalError("ViewController 'Window' is not of the expected class NSWindowController.") - } - return vc - } - } -} - -enum StoryboardSegue { - enum Message: String, StoryboardSegueType { - case Embed - case Modal - case Popover - case Sheet - case Show - case Public = "public" - } -} -// swiftlint:enable explicit_type_interface identifier_name line_length type_body_length type_name - -private final class BundleToken {} diff --git a/Tests/Expected/Storyboards-macOS/lowercase-context-empty.swift b/Tests/Expected/Storyboards-macOS/lowercase-context-empty.swift deleted file mode 100644 index 55455a6..0000000 --- a/Tests/Expected/Storyboards-macOS/lowercase-context-empty.swift +++ /dev/null @@ -1,3 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// No storyboard found diff --git a/Tests/Expected/Storyboards-macOS/default-context-all-customname.swift b/Tests/Expected/Storyboards-macOS/swift2-context-all-customname.swift similarity index 100% rename from Tests/Expected/Storyboards-macOS/default-context-all-customname.swift rename to Tests/Expected/Storyboards-macOS/swift2-context-all-customname.swift diff --git a/Tests/Expected/Storyboards-macOS/default-context-all-ignore-module.swift b/Tests/Expected/Storyboards-macOS/swift2-context-all-ignore-module.swift similarity index 100% rename from Tests/Expected/Storyboards-macOS/default-context-all-ignore-module.swift rename to Tests/Expected/Storyboards-macOS/swift2-context-all-ignore-module.swift diff --git a/Tests/Expected/Storyboards-macOS/default-context-all.swift b/Tests/Expected/Storyboards-macOS/swift2-context-all.swift similarity index 100% rename from Tests/Expected/Storyboards-macOS/default-context-all.swift rename to Tests/Expected/Storyboards-macOS/swift2-context-all.swift diff --git a/Tests/Expected/Storyboards-iOS/lowercase-context-empty.swift b/Tests/Expected/Storyboards-macOS/swift2-context-empty.swift similarity index 100% rename from Tests/Expected/Storyboards-iOS/lowercase-context-empty.swift rename to Tests/Expected/Storyboards-macOS/swift2-context-empty.swift diff --git a/Tests/Expected/Strings/dot-syntax-context-defaults-customname.swift b/Tests/Expected/Strings/dot-syntax-swift2-context-defaults-customname.swift similarity index 100% rename from Tests/Expected/Strings/dot-syntax-context-defaults-customname.swift rename to Tests/Expected/Strings/dot-syntax-swift2-context-defaults-customname.swift diff --git a/Tests/Expected/Strings/dot-syntax-context-defaults.swift b/Tests/Expected/Strings/dot-syntax-swift2-context-defaults.swift similarity index 100% rename from Tests/Expected/Strings/dot-syntax-context-defaults.swift rename to Tests/Expected/Strings/dot-syntax-swift2-context-defaults.swift diff --git a/Tests/Expected/Strings/default-context-empty.swift b/Tests/Expected/Strings/dot-syntax-swift2-context-empty.swift similarity index 100% rename from Tests/Expected/Strings/default-context-empty.swift rename to Tests/Expected/Strings/dot-syntax-swift2-context-empty.swift diff --git a/Tests/Expected/Strings/default-context-defaults-customname.swift b/Tests/Expected/Strings/flat-swift2-context-defaults-customname.swift similarity index 100% rename from Tests/Expected/Strings/default-context-defaults-customname.swift rename to Tests/Expected/Strings/flat-swift2-context-defaults-customname.swift diff --git a/Tests/Expected/Strings/default-context-defaults.swift b/Tests/Expected/Strings/flat-swift2-context-defaults.swift similarity index 100% rename from Tests/Expected/Strings/default-context-defaults.swift rename to Tests/Expected/Strings/flat-swift2-context-defaults.swift diff --git a/Tests/Expected/Strings/dot-syntax-context-empty.swift b/Tests/Expected/Strings/flat-swift2-context-empty.swift similarity index 100% rename from Tests/Expected/Strings/dot-syntax-context-empty.swift rename to Tests/Expected/Strings/flat-swift2-context-empty.swift diff --git a/Tests/Expected/Strings/swift3-context-defaults-customname.swift b/Tests/Expected/Strings/flat-swift3-context-defaults-customname.swift similarity index 100% rename from Tests/Expected/Strings/swift3-context-defaults-customname.swift rename to Tests/Expected/Strings/flat-swift3-context-defaults-customname.swift diff --git a/Tests/Expected/Strings/swift3-context-defaults.swift b/Tests/Expected/Strings/flat-swift3-context-defaults.swift similarity index 100% rename from Tests/Expected/Strings/swift3-context-defaults.swift rename to Tests/Expected/Strings/flat-swift3-context-defaults.swift diff --git a/Tests/Expected/Strings/genstrings-context-empty.swift b/Tests/Expected/Strings/flat-swift3-context-empty.swift similarity index 100% rename from Tests/Expected/Strings/genstrings-context-empty.swift rename to Tests/Expected/Strings/flat-swift3-context-empty.swift diff --git a/Tests/Expected/Strings/genstrings-context-defaults-customname.swift b/Tests/Expected/Strings/genstrings-context-defaults-customname.swift deleted file mode 100644 index 2eb1eb6..0000000 --- a/Tests/Expected/Strings/genstrings-context-defaults-customname.swift +++ /dev/null @@ -1,84 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -import Foundation - -// swiftlint:disable file_length - -// swiftlint:disable identifier_name line_length type_body_length -enum XCTLoc { - /// Some alert body there - case AlertMessage - /// Title of the alert - case AlertTitle - /// These are %3$@'s %1$d %2$@. - case ObjectOwnership(Int, String, String) - /// Hello, my name is %@ and I'm %d - case Private(String, Int) - /// You have %d apples - case ApplesCount(Int) - /// Those %d bananas belong to %@. - case BananasOwner(Int, String) - /// Some Reserved Keyword there - case SettingsNavigationBarSelf - /// DeepSettings - case SettingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep - /// Settings - case SettingsNavigationBarTitleEvenDeeper - /// Here you can change some user profile settings. - case SeTTingsUSerProFileSectioNFooterText - /// User Profile Settings - case SettingsUserProfileSectionHeaderTitle -} - -extension XCTLoc: CustomStringConvertible { - var description: String { return self.string } - - var string: String { - switch self { - case .AlertMessage: - let format = NSLocalizedString("alert_message", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return XCTLoc.tr(format) - case .AlertTitle: - let format = NSLocalizedString("alert_title", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return XCTLoc.tr(format) - case .ObjectOwnership(let p1, let p2, let p3): - let format = NSLocalizedString("ObjectOwnership", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return XCTLoc.tr(format, p1, p2, p3) - case .Private(let p1, let p2): - let format = NSLocalizedString("private", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return XCTLoc.tr(format, p1, p2) - case .ApplesCount(let p1): - let format = NSLocalizedString("apples.count", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return XCTLoc.tr(format, p1) - case .BananasOwner(let p1, let p2): - let format = NSLocalizedString("bananas.owner", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return XCTLoc.tr(format, p1, p2) - case .SettingsNavigationBarSelf: - let format = NSLocalizedString("settings.navigation-bar.self", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return XCTLoc.tr(format) - case .SettingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep: - let format = NSLocalizedString("settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return XCTLoc.tr(format) - case .SettingsNavigationBarTitleEvenDeeper: - let format = NSLocalizedString("settings.navigation-bar.title.even.deeper", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return XCTLoc.tr(format) - case .SeTTingsUSerProFileSectioNFooterText: - let format = NSLocalizedString("seTTings.uSer-proFile-sectioN.footer_text", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return XCTLoc.tr(format) - case .SettingsUserProfileSectionHeaderTitle: - let format = NSLocalizedString("SETTINGS.USER_PROFILE_SECTION.HEADER_TITLE", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return XCTLoc.tr(format) - } - } - - private static func tr(format: String, _ args: CVarArgType...) -> String { - return String(format: format, locale: NSLocale.currentLocale(), arguments: args) - } -} -// swiftlint:enable identifier_name line_length type_body_length - -func tr(key: XCTLoc) -> String { - return key.string -} - -private final class BundleToken {} diff --git a/Tests/Expected/Strings/genstrings-context-defaults.swift b/Tests/Expected/Strings/genstrings-context-defaults.swift deleted file mode 100644 index 11e831d..0000000 --- a/Tests/Expected/Strings/genstrings-context-defaults.swift +++ /dev/null @@ -1,84 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -import Foundation - -// swiftlint:disable file_length - -// swiftlint:disable identifier_name line_length type_body_length -enum L10n { - /// Some alert body there - case AlertMessage - /// Title of the alert - case AlertTitle - /// These are %3$@'s %1$d %2$@. - case ObjectOwnership(Int, String, String) - /// Hello, my name is %@ and I'm %d - case Private(String, Int) - /// You have %d apples - case ApplesCount(Int) - /// Those %d bananas belong to %@. - case BananasOwner(Int, String) - /// Some Reserved Keyword there - case SettingsNavigationBarSelf - /// DeepSettings - case SettingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep - /// Settings - case SettingsNavigationBarTitleEvenDeeper - /// Here you can change some user profile settings. - case SeTTingsUSerProFileSectioNFooterText - /// User Profile Settings - case SettingsUserProfileSectionHeaderTitle -} - -extension L10n: CustomStringConvertible { - var description: String { return self.string } - - var string: String { - switch self { - case .AlertMessage: - let format = NSLocalizedString("alert_message", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return L10n.tr(format) - case .AlertTitle: - let format = NSLocalizedString("alert_title", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return L10n.tr(format) - case .ObjectOwnership(let p1, let p2, let p3): - let format = NSLocalizedString("ObjectOwnership", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return L10n.tr(format, p1, p2, p3) - case .Private(let p1, let p2): - let format = NSLocalizedString("private", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return L10n.tr(format, p1, p2) - case .ApplesCount(let p1): - let format = NSLocalizedString("apples.count", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return L10n.tr(format, p1) - case .BananasOwner(let p1, let p2): - let format = NSLocalizedString("bananas.owner", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return L10n.tr(format, p1, p2) - case .SettingsNavigationBarSelf: - let format = NSLocalizedString("settings.navigation-bar.self", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return L10n.tr(format) - case .SettingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep: - let format = NSLocalizedString("settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return L10n.tr(format) - case .SettingsNavigationBarTitleEvenDeeper: - let format = NSLocalizedString("settings.navigation-bar.title.even.deeper", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return L10n.tr(format) - case .SeTTingsUSerProFileSectioNFooterText: - let format = NSLocalizedString("seTTings.uSer-proFile-sectioN.footer_text", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return L10n.tr(format) - case .SettingsUserProfileSectionHeaderTitle: - let format = NSLocalizedString("SETTINGS.USER_PROFILE_SECTION.HEADER_TITLE", bundle: NSBundle(forClass: BundleToken.self), comment: "") - return L10n.tr(format) - } - } - - private static func tr(format: String, _ args: CVarArgType...) -> String { - return String(format: format, locale: NSLocale.currentLocale(), arguments: args) - } -} -// swiftlint:enable identifier_name line_length type_body_length - -func tr(key: L10n) -> String { - return key.string -} - -private final class BundleToken {} diff --git a/Tests/Expected/Strings/no-comments-swift3-context-defaults-customname.swift b/Tests/Expected/Strings/no-comments-swift3-context-defaults-customname.swift deleted file mode 100644 index 065ce2c..0000000 --- a/Tests/Expected/Strings/no-comments-swift3-context-defaults-customname.swift +++ /dev/null @@ -1,63 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -import Foundation - -// swiftlint:disable file_length - -// swiftlint:disable identifier_name line_length type_body_length -enum XCTLoc { - case alertMessage - case alertTitle - case objectOwnership(Int, String, String) - case `private`(String, Int) - case applesCount(Int) - case bananasOwner(Int, String) - case settingsNavigationBarSelf - case settingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep - case settingsNavigationBarTitleEvenDeeper - case seTTingsUSerProFileSectioNFooterText - case settingsUserProfileSectionHeaderTitle -} - -extension XCTLoc: CustomStringConvertible { - var description: String { return self.string } - - var string: String { - switch self { - case .alertMessage: - return XCTLoc.tr(key: "alert_message") - case .alertTitle: - return XCTLoc.tr(key: "alert_title") - case .objectOwnership(let p1, let p2, let p3): - return XCTLoc.tr(key: "ObjectOwnership", p1, p2, p3) - case .`private`(let p1, let p2): - return XCTLoc.tr(key: "private", p1, p2) - case .applesCount(let p1): - return XCTLoc.tr(key: "apples.count", p1) - case .bananasOwner(let p1, let p2): - return XCTLoc.tr(key: "bananas.owner", p1, p2) - case .settingsNavigationBarSelf: - return XCTLoc.tr(key: "settings.navigation-bar.self") - case .settingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep: - return XCTLoc.tr(key: "settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") - case .settingsNavigationBarTitleEvenDeeper: - return XCTLoc.tr(key: "settings.navigation-bar.title.even.deeper") - case .seTTingsUSerProFileSectioNFooterText: - return XCTLoc.tr(key: "seTTings.uSer-proFile-sectioN.footer_text") - case .settingsUserProfileSectionHeaderTitle: - return XCTLoc.tr(key: "SETTINGS.USER_PROFILE_SECTION.HEADER_TITLE") - } - } - - private static func tr(key: String, _ args: CVarArg...) -> String { - let format = NSLocalizedString(key, bundle: Bundle(for: BundleToken.self), comment: "") - return String(format: format, locale: Locale.current, arguments: args) - } -} -// swiftlint:enable identifier_name line_length type_body_length - -func tr(_ key: XCTLoc) -> String { - return key.string -} - -private final class BundleToken {} diff --git a/Tests/Expected/Strings/no-comments-swift3-context-defaults.swift b/Tests/Expected/Strings/no-comments-swift3-context-defaults.swift deleted file mode 100644 index 0ec798b..0000000 --- a/Tests/Expected/Strings/no-comments-swift3-context-defaults.swift +++ /dev/null @@ -1,63 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -import Foundation - -// swiftlint:disable file_length - -// swiftlint:disable identifier_name line_length type_body_length -enum L10n { - case alertMessage - case alertTitle - case objectOwnership(Int, String, String) - case `private`(String, Int) - case applesCount(Int) - case bananasOwner(Int, String) - case settingsNavigationBarSelf - case settingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep - case settingsNavigationBarTitleEvenDeeper - case seTTingsUSerProFileSectioNFooterText - case settingsUserProfileSectionHeaderTitle -} - -extension L10n: CustomStringConvertible { - var description: String { return self.string } - - var string: String { - switch self { - case .alertMessage: - return L10n.tr(key: "alert_message") - case .alertTitle: - return L10n.tr(key: "alert_title") - case .objectOwnership(let p1, let p2, let p3): - return L10n.tr(key: "ObjectOwnership", p1, p2, p3) - case .`private`(let p1, let p2): - return L10n.tr(key: "private", p1, p2) - case .applesCount(let p1): - return L10n.tr(key: "apples.count", p1) - case .bananasOwner(let p1, let p2): - return L10n.tr(key: "bananas.owner", p1, p2) - case .settingsNavigationBarSelf: - return L10n.tr(key: "settings.navigation-bar.self") - case .settingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep: - return L10n.tr(key: "settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") - case .settingsNavigationBarTitleEvenDeeper: - return L10n.tr(key: "settings.navigation-bar.title.even.deeper") - case .seTTingsUSerProFileSectioNFooterText: - return L10n.tr(key: "seTTings.uSer-proFile-sectioN.footer_text") - case .settingsUserProfileSectionHeaderTitle: - return L10n.tr(key: "SETTINGS.USER_PROFILE_SECTION.HEADER_TITLE") - } - } - - private static func tr(key: String, _ args: CVarArg...) -> String { - let format = NSLocalizedString(key, bundle: Bundle(for: BundleToken.self), comment: "") - return String(format: format, locale: Locale.current, arguments: args) - } -} -// swiftlint:enable identifier_name line_length type_body_length - -func tr(_ key: L10n) -> String { - return key.string -} - -private final class BundleToken {} diff --git a/Tests/Expected/Strings/no-comments-swift3-context-empty.swift b/Tests/Expected/Strings/no-comments-swift3-context-empty.swift deleted file mode 100644 index 12a3980..0000000 --- a/Tests/Expected/Strings/no-comments-swift3-context-empty.swift +++ /dev/null @@ -1,3 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// No string found diff --git a/Tests/Expected/Strings/structured-context-defaults-customname.swift b/Tests/Expected/Strings/structured-context-defaults-customname.swift deleted file mode 100644 index 6e747c9..0000000 --- a/Tests/Expected/Strings/structured-context-defaults-customname.swift +++ /dev/null @@ -1,202 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -import Foundation - -// swiftlint:disable file_length - -// swiftlint:disable identifier_name line_length nesting type_body_length -enum XCTLoc { - /// Some alert body there - case AlertMessage - /// Title of the alert - case AlertTitle - /// These are %3$@'s %1$d %2$@. - case ObjectOwnership(Int, String, String) - /// Hello, my name is %@ and I'm %d - case Private(String, Int) - - case Apples(ApplesXCTLoc) - enum ApplesXCTLoc { - /// You have %d apples - case Count(Int) - } - - case Bananas(BananasXCTLoc) - enum BananasXCTLoc { - /// Those %d bananas belong to %@. - case Owner(Int, String) - } - - case Settings(SettingsXCTLoc) - enum SettingsXCTLoc { - - case NavigationBar(NavigationBarXCTLoc) - enum NavigationBarXCTLoc { - /// Some Reserved Keyword there - case `Self` - - case Title(TitleXCTLoc) - enum TitleXCTLoc { - - case Deeper(DeeperXCTLoc) - enum DeeperXCTLoc { - - case Than(ThanXCTLoc) - enum ThanXCTLoc { - - case We(WeXCTLoc) - enum WeXCTLoc { - - case Can(CanXCTLoc) - enum CanXCTLoc { - - case Handle(HandleXCTLoc) - enum HandleXCTLoc { - - case No(NoXCTLoc) - enum NoXCTLoc { - - case Really(ReallyXCTLoc) - enum ReallyXCTLoc { - - case This(ThisXCTLoc) - enum ThisXCTLoc { - - case Is(IsXCTLoc) - enum IsXCTLoc { - /// DeepSettings - case Deep - } - } - } - } - } - } - } - } - } - - case Even(EvenXCTLoc) - enum EvenXCTLoc { - /// Settings - case Deeper - } - } - } - - case UserProfileSection(UserProfileSectionXCTLoc) - enum UserProfileSectionXCTLoc { - /// Here you can change some user profile settings. - case FooterText - /// User Profile Settings - case HeaderTitle - } - } -} - -extension XCTLoc: CustomStringConvertible { - var description: String { return self.string } - - var string: String { - switch self { - case .AlertMessage: - return XCTLoc.tr("alert_message") - case .AlertTitle: - return XCTLoc.tr("alert_title") - case .ObjectOwnership(let p1, let p2, let p3): - return XCTLoc.tr("ObjectOwnership", p1, p2, p3) - case .Private(let p1, let p2): - return XCTLoc.tr("private", p1, p2) - case .Apples(let levelSubKeyApples): - - switch levelSubKeyApples { - case .Count(let p1): - return XCTLoc.tr("apples.count", p1) - } - case .Bananas(let levelSubKeyBananas): - - switch levelSubKeyBananas { - case .Owner(let p1, let p2): - return XCTLoc.tr("bananas.owner", p1, p2) - } - case .Settings(let levelSubKeySettings): - - switch levelSubKeySettings { - case .NavigationBar(let levelSubSubKeyNavigationBar): - - switch levelSubSubKeyNavigationBar { - case .`Self`: - return XCTLoc.tr("settings.navigation-bar.self") - case .Title(let levelSubSubSubKeyTitle): - - switch levelSubSubSubKeyTitle { - case .Deeper(let levelSubSubSubSubKeyDeeper): - - switch levelSubSubSubSubKeyDeeper { - case .Than(let levelSubSubSubSubSubKeyThan): - - switch levelSubSubSubSubSubKeyThan { - case .We(let levelSubSubSubSubSubSubKeyWe): - - switch levelSubSubSubSubSubSubKeyWe { - case .Can(let levelSubSubSubSubSubSubSubKeyCan): - - switch levelSubSubSubSubSubSubSubKeyCan { - case .Handle(let levelSubSubSubSubSubSubSubSubKeyHandle): - - switch levelSubSubSubSubSubSubSubSubKeyHandle { - case .No(let levelSubSubSubSubSubSubSubSubSubKeyNo): - - switch levelSubSubSubSubSubSubSubSubSubKeyNo { - case .Really(let levelSubSubSubSubSubSubSubSubSubSubKeyReally): - - switch levelSubSubSubSubSubSubSubSubSubSubKeyReally { - case .This(let levelSubSubSubSubSubSubSubSubSubSubSubKeyThis): - - switch levelSubSubSubSubSubSubSubSubSubSubSubKeyThis { - case .Is(let levelSubSubSubSubSubSubSubSubSubSubSubSubKeyIs): - - switch levelSubSubSubSubSubSubSubSubSubSubSubSubKeyIs { - case .Deep: - return XCTLoc.tr("settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") - } - } - } - } - } - } - } - } - } - case .Even(let levelSubSubSubSubKeyEven): - - switch levelSubSubSubSubKeyEven { - case .Deeper: - return XCTLoc.tr("settings.navigation-bar.title.even.deeper") - } - } - } - case .UserProfileSection(let levelSubSubKeyUserProfileSection): - - switch levelSubSubKeyUserProfileSection { - case .FooterText: - return XCTLoc.tr("seTTings.uSer-proFile-sectioN.footer_text") - case .HeaderTitle: - return XCTLoc.tr("SETTINGS.USER_PROFILE_SECTION.HEADER_TITLE") - } - } - } - } - - private static func tr(key: String, _ args: CVarArgType...) -> String { - let format = NSLocalizedString(key, bundle: NSBundle(forClass: BundleToken.self), comment: "") - return String(format: format, locale: NSLocale.currentLocale(), arguments: args) - } -} -// swiftlint:enable identifier_name line_length nesting type_body_length - -func tr(key: XCTLoc) -> String { - return key.string -} - -private final class BundleToken {} diff --git a/Tests/Expected/Strings/structured-context-defaults.swift b/Tests/Expected/Strings/structured-context-defaults.swift deleted file mode 100644 index 54c70f2..0000000 --- a/Tests/Expected/Strings/structured-context-defaults.swift +++ /dev/null @@ -1,202 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -import Foundation - -// swiftlint:disable file_length - -// swiftlint:disable identifier_name line_length nesting type_body_length -enum L10n { - /// Some alert body there - case AlertMessage - /// Title of the alert - case AlertTitle - /// These are %3$@'s %1$d %2$@. - case ObjectOwnership(Int, String, String) - /// Hello, my name is %@ and I'm %d - case Private(String, Int) - - case Apples(ApplesL10n) - enum ApplesL10n { - /// You have %d apples - case Count(Int) - } - - case Bananas(BananasL10n) - enum BananasL10n { - /// Those %d bananas belong to %@. - case Owner(Int, String) - } - - case Settings(SettingsL10n) - enum SettingsL10n { - - case NavigationBar(NavigationBarL10n) - enum NavigationBarL10n { - /// Some Reserved Keyword there - case `Self` - - case Title(TitleL10n) - enum TitleL10n { - - case Deeper(DeeperL10n) - enum DeeperL10n { - - case Than(ThanL10n) - enum ThanL10n { - - case We(WeL10n) - enum WeL10n { - - case Can(CanL10n) - enum CanL10n { - - case Handle(HandleL10n) - enum HandleL10n { - - case No(NoL10n) - enum NoL10n { - - case Really(ReallyL10n) - enum ReallyL10n { - - case This(ThisL10n) - enum ThisL10n { - - case Is(IsL10n) - enum IsL10n { - /// DeepSettings - case Deep - } - } - } - } - } - } - } - } - } - - case Even(EvenL10n) - enum EvenL10n { - /// Settings - case Deeper - } - } - } - - case UserProfileSection(UserProfileSectionL10n) - enum UserProfileSectionL10n { - /// Here you can change some user profile settings. - case FooterText - /// User Profile Settings - case HeaderTitle - } - } -} - -extension L10n: CustomStringConvertible { - var description: String { return self.string } - - var string: String { - switch self { - case .AlertMessage: - return L10n.tr("alert_message") - case .AlertTitle: - return L10n.tr("alert_title") - case .ObjectOwnership(let p1, let p2, let p3): - return L10n.tr("ObjectOwnership", p1, p2, p3) - case .Private(let p1, let p2): - return L10n.tr("private", p1, p2) - case .Apples(let levelSubKeyApples): - - switch levelSubKeyApples { - case .Count(let p1): - return L10n.tr("apples.count", p1) - } - case .Bananas(let levelSubKeyBananas): - - switch levelSubKeyBananas { - case .Owner(let p1, let p2): - return L10n.tr("bananas.owner", p1, p2) - } - case .Settings(let levelSubKeySettings): - - switch levelSubKeySettings { - case .NavigationBar(let levelSubSubKeyNavigationBar): - - switch levelSubSubKeyNavigationBar { - case .`Self`: - return L10n.tr("settings.navigation-bar.self") - case .Title(let levelSubSubSubKeyTitle): - - switch levelSubSubSubKeyTitle { - case .Deeper(let levelSubSubSubSubKeyDeeper): - - switch levelSubSubSubSubKeyDeeper { - case .Than(let levelSubSubSubSubSubKeyThan): - - switch levelSubSubSubSubSubKeyThan { - case .We(let levelSubSubSubSubSubSubKeyWe): - - switch levelSubSubSubSubSubSubKeyWe { - case .Can(let levelSubSubSubSubSubSubSubKeyCan): - - switch levelSubSubSubSubSubSubSubKeyCan { - case .Handle(let levelSubSubSubSubSubSubSubSubKeyHandle): - - switch levelSubSubSubSubSubSubSubSubKeyHandle { - case .No(let levelSubSubSubSubSubSubSubSubSubKeyNo): - - switch levelSubSubSubSubSubSubSubSubSubKeyNo { - case .Really(let levelSubSubSubSubSubSubSubSubSubSubKeyReally): - - switch levelSubSubSubSubSubSubSubSubSubSubKeyReally { - case .This(let levelSubSubSubSubSubSubSubSubSubSubSubKeyThis): - - switch levelSubSubSubSubSubSubSubSubSubSubSubKeyThis { - case .Is(let levelSubSubSubSubSubSubSubSubSubSubSubSubKeyIs): - - switch levelSubSubSubSubSubSubSubSubSubSubSubSubKeyIs { - case .Deep: - return L10n.tr("settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") - } - } - } - } - } - } - } - } - } - case .Even(let levelSubSubSubSubKeyEven): - - switch levelSubSubSubSubKeyEven { - case .Deeper: - return L10n.tr("settings.navigation-bar.title.even.deeper") - } - } - } - case .UserProfileSection(let levelSubSubKeyUserProfileSection): - - switch levelSubSubKeyUserProfileSection { - case .FooterText: - return L10n.tr("seTTings.uSer-proFile-sectioN.footer_text") - case .HeaderTitle: - return L10n.tr("SETTINGS.USER_PROFILE_SECTION.HEADER_TITLE") - } - } - } - } - - private static func tr(key: String, _ args: CVarArgType...) -> String { - let format = NSLocalizedString(key, bundle: NSBundle(forClass: BundleToken.self), comment: "") - return String(format: format, locale: NSLocale.currentLocale(), arguments: args) - } -} -// swiftlint:enable identifier_name line_length nesting type_body_length - -func tr(key: L10n) -> String { - return key.string -} - -private final class BundleToken {} diff --git a/Tests/Expected/Strings/structured-context-empty.swift b/Tests/Expected/Strings/structured-context-empty.swift deleted file mode 100644 index 12a3980..0000000 --- a/Tests/Expected/Strings/structured-context-empty.swift +++ /dev/null @@ -1,3 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// No string found diff --git a/Tests/Expected/Strings/swift3-context-empty.swift b/Tests/Expected/Strings/swift3-context-empty.swift deleted file mode 100644 index 12a3980..0000000 --- a/Tests/Expected/Strings/swift3-context-empty.swift +++ /dev/null @@ -1,3 +0,0 @@ -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -// No string found From 4b6e6de180b2136ebef5d910e9776efa3b394413 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Thu, 11 May 2017 22:07:56 +0200 Subject: [PATCH 03/12] update tests --- Tests/TemplatesTests/ColorsTests.swift | 11 +----- Tests/TemplatesTests/FontsTests.swift | 4 +- Tests/TemplatesTests/ImagesTests.swift | 25 +------------ .../StoryboardsMacOSTests.swift | 17 ++------- .../TemplatesTests/StoryboardsiOSTests.swift | 20 +--------- Tests/TemplatesTests/StringsTests.swift | 37 ++++--------------- 6 files changed, 20 insertions(+), 94 deletions(-) diff --git a/Tests/TemplatesTests/ColorsTests.swift b/Tests/TemplatesTests/ColorsTests.swift index ad5aaf8..63eb347 100644 --- a/Tests/TemplatesTests/ColorsTests.swift +++ b/Tests/TemplatesTests/ColorsTests.swift @@ -26,20 +26,13 @@ class ColorsTests: XCTestCase { ] } - func testDefault() { - test(template: "default", + func testSwift2() { + test(template: "swift2", contextNames: Contexts.all, directory: .colors, contextVariations: variations) } - func testRawValue() { - test(template: "rawValue", - contextNames: Contexts.rawOnly, - directory: .colors, - contextVariations: variations) - } - func testSwift3() { test(template: "swift3", contextNames: Contexts.all, diff --git a/Tests/TemplatesTests/FontsTests.swift b/Tests/TemplatesTests/FontsTests.swift index 02da6a9..1c0add9 100644 --- a/Tests/TemplatesTests/FontsTests.swift +++ b/Tests/TemplatesTests/FontsTests.swift @@ -27,8 +27,8 @@ class FontsTests: XCTestCase { ] } - func testDefault() { - test(template: "default", + func testSwift2() { + test(template: "swift2", contextNames: Contexts.all, directory: .fonts, contextVariations: variations) diff --git a/Tests/TemplatesTests/ImagesTests.swift b/Tests/TemplatesTests/ImagesTests.swift index eb30f7a..c870511 100644 --- a/Tests/TemplatesTests/ImagesTests.swift +++ b/Tests/TemplatesTests/ImagesTests.swift @@ -25,15 +25,8 @@ class ImagesTests: XCTestCase { ] } - func testDefault() { - test(template: "default", - contextNames: Contexts.all, - directory: .images, - contextVariations: variations) - } - - func testAllValues() { - test(template: "allvalues", + func testSwift2() { + test(template: "swift2", contextNames: Contexts.all, directory: .images, contextVariations: variations) @@ -45,18 +38,4 @@ class ImagesTests: XCTestCase { directory: .images, contextVariations: variations) } - - func testDotSyntax() { - test(template: "dot-syntax", - contextNames: Contexts.all, - directory: .images, - contextVariations: variations) - } - - func testDotSyntaxSwift3() { - test(template: "dot-syntax-swift3", - contextNames: Contexts.all, - directory: .images, - contextVariations: variations) - } } diff --git a/Tests/TemplatesTests/StoryboardsMacOSTests.swift b/Tests/TemplatesTests/StoryboardsMacOSTests.swift index 3cc097a..41788ed 100644 --- a/Tests/TemplatesTests/StoryboardsMacOSTests.swift +++ b/Tests/TemplatesTests/StoryboardsMacOSTests.swift @@ -45,30 +45,21 @@ class StoryboardsMacOSTests: XCTestCase { } } - func testDefault() { - test(template: "osx-default", + func testSwift2() { + test(template: "macOS-swift2", contextNames: Contexts.all, - outputPrefix: "default", + outputPrefix: "swift2", directory: .storyboards, resourceDirectory: .storyboardsMacOS, contextVariations: variations) } func testSwift3() { - test(template: "osx-swift3", + test(template: "macOS-swift3", contextNames: Contexts.all, outputPrefix: "swift3", directory: .storyboards, resourceDirectory: .storyboardsMacOS, contextVariations: variations) } - - func testLowercase() { - test(template: "osx-lowercase", - contextNames: Contexts.all, - outputPrefix: "lowercase", - directory: .storyboards, - resourceDirectory: .storyboardsMacOS, - contextVariations: variations) - } } diff --git a/Tests/TemplatesTests/StoryboardsiOSTests.swift b/Tests/TemplatesTests/StoryboardsiOSTests.swift index f5177a1..fe8877a 100644 --- a/Tests/TemplatesTests/StoryboardsiOSTests.swift +++ b/Tests/TemplatesTests/StoryboardsiOSTests.swift @@ -40,8 +40,8 @@ class StoryboardsiOSTests: XCTestCase { ] } - func testDefault() { - test(template: "default", + func testSwift2() { + test(template: "swift2", contextNames: Contexts.all, directory: .storyboards, resourceDirectory: .storyboardsiOS, @@ -55,20 +55,4 @@ class StoryboardsiOSTests: XCTestCase { resourceDirectory: .storyboardsiOS, contextVariations: variations) } - - func testLowercase() { - test(template: "lowercase", - contextNames: Contexts.all, - directory: .storyboards, - resourceDirectory: .storyboardsiOS, - contextVariations: variations) - } - - func testUppercase() { - test(template: "uppercase", - contextNames: Contexts.all, - directory: .storyboards, - resourceDirectory: .storyboardsiOS, - contextVariations: variations) - } } diff --git a/Tests/TemplatesTests/StringsTests.swift b/Tests/TemplatesTests/StringsTests.swift index 2dd0785..305b928 100644 --- a/Tests/TemplatesTests/StringsTests.swift +++ b/Tests/TemplatesTests/StringsTests.swift @@ -25,50 +25,29 @@ class StringsTests: XCTestCase { ] } - func testDefault() { - test(template: "default", + func testDotSyntaxSwift2() { + test(template: "dot-syntax-swift2", contextNames: Contexts.all, directory: .strings, contextVariations: variations) } - func testSwift3() { - test(template: "swift3", - contextNames: Contexts.all, - directory: .strings, - contextVariations: variations) - } - - func testNoCommentsSwift3() { - test(template: "no-comments-swift3", - contextNames: Contexts.all, - directory: .strings, - contextVariations: variations) - } - - func testGenstrings() { - test(template: "genstrings", - contextNames: Contexts.all, - directory: .strings, - contextVariations: variations) - } - - func testStructured() { - test(template: "structured", + func testDotSyntaxSwift3() { + test(template: "dot-syntax-swift3", contextNames: Contexts.all, directory: .strings, contextVariations: variations) } - func testDotSyntax() { - test(template: "dot-syntax", + func testFlatSwift2() { + test(template: "flat-swift2", contextNames: Contexts.all, directory: .strings, contextVariations: variations) } - func testDotSyntaxSwift3() { - test(template: "dot-syntax-swift3", + func testFlatSwift3() { + test(template: "flat-swift3", contextNames: Contexts.all, directory: .strings, contextVariations: variations) From ec90412f0569ef96b62ec70be6bc4eb194c63c2d Mon Sep 17 00:00:00 2001 From: David Jennes Date: Thu, 11 May 2017 23:06:00 +0200 Subject: [PATCH 04/12] Add a `allValues` property to the images template --- .../swift2-context-defaults-customname.swift | 11 ++++++++ .../Images/swift2-context-defaults.swift | 11 ++++++++ .../swift3-context-defaults-customname.swift | 11 ++++++++ .../Images/swift3-context-defaults.swift | 11 ++++++++ templates/images/swift2.stencil | 26 ++++++++++++++++--- templates/images/swift3.stencil | 26 ++++++++++++++++--- 6 files changed, 88 insertions(+), 8 deletions(-) diff --git a/Tests/Expected/Images/swift2-context-defaults-customname.swift b/Tests/Expected/Images/swift2-context-defaults-customname.swift index d9c14f5..d50fe76 100644 --- a/Tests/Expected/Images/swift2-context-defaults-customname.swift +++ b/Tests/Expected/Images/swift2-context-defaults-customname.swift @@ -57,6 +57,17 @@ enum XCTImages { static let Tomato: XCTImagesType = "Round/Tomato" } } + + static let allValues = [ + Exotic.Banana, + Exotic.Mango, + Private, + Round.Apricot, + Round.Orange, + Round.Red.Apple, + Round.Red.Double.Cherry, + Round.Red.Tomato + ] } // swiftlint:enable identifier_name line_length nesting type_body_length type_name diff --git a/Tests/Expected/Images/swift2-context-defaults.swift b/Tests/Expected/Images/swift2-context-defaults.swift index 319dc74..32e0127 100644 --- a/Tests/Expected/Images/swift2-context-defaults.swift +++ b/Tests/Expected/Images/swift2-context-defaults.swift @@ -57,6 +57,17 @@ enum Asset { static let Tomato: AssetType = "Round/Tomato" } } + + static let allValues = [ + Exotic.Banana, + Exotic.Mango, + Private, + Round.Apricot, + Round.Orange, + Round.Red.Apple, + Round.Red.Double.Cherry, + Round.Red.Tomato + ] } // swiftlint:enable identifier_name line_length nesting type_body_length type_name diff --git a/Tests/Expected/Images/swift3-context-defaults-customname.swift b/Tests/Expected/Images/swift3-context-defaults-customname.swift index cef531a..40e331d 100644 --- a/Tests/Expected/Images/swift3-context-defaults-customname.swift +++ b/Tests/Expected/Images/swift3-context-defaults-customname.swift @@ -57,6 +57,17 @@ enum XCTImages { static let tomato: XCTImagesType = "Round/Tomato" } } + + static let allValues = [ + Exotic.banana, + Exotic.mango, + `private`, + Round.apricot, + Round.orange, + Round.Red.apple, + Round.Red.Double.cherry, + Round.Red.tomato + ] } // swiftlint:enable identifier_name line_length nesting type_body_length type_name diff --git a/Tests/Expected/Images/swift3-context-defaults.swift b/Tests/Expected/Images/swift3-context-defaults.swift index 781c301..e06c263 100644 --- a/Tests/Expected/Images/swift3-context-defaults.swift +++ b/Tests/Expected/Images/swift3-context-defaults.swift @@ -57,6 +57,17 @@ enum Asset { static let tomato: AssetType = "Round/Tomato" } } + + static let allValues = [ + Exotic.banana, + Exotic.mango, + `private`, + Round.apricot, + Round.orange, + Round.Red.apple, + Round.Red.Double.cherry, + Round.Red.tomato + ] } // swiftlint:enable identifier_name line_length nesting type_body_length type_name diff --git a/templates/images/swift2.stencil b/templates/images/swift2.stencil index f65b15a..786fe73 100644 --- a/templates/images/swift2.stencil +++ b/templates/images/swift2.stencil @@ -40,29 +40,47 @@ struct {{enumName}}Type: StringLiteralConvertible { self.init(stringLiteral: value) } } -{% macro recursiveBlock images sp %} +{% macro enumBlock images sp %} +{{sp}} {% call casesBlock images sp %} + +{{sp}} static let allValues = [ +{{sp}} {% set sp2 %}{{sp}} {% endset %} +{{sp}} {% call allValuesBlock images "" false sp2 %} +{{sp}} ] +{% endmacro %} +{% macro casesBlock images sp %} {{sp}} {% for image in images %} {{sp}} {% if not image.items %} {{sp}} static let {{image.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}: {{enumName}}Type = "{{image.value}}" {{sp}} {% else %} {{sp}} enum {{image.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}} { {{sp}} {% set sp2 %}{{sp}} {% endset %} -{{sp}} {% call recursiveBlock image.items sp2 %} +{{sp}} {% call casesBlock image.items sp2 %} {{sp}} } {{sp}} {% endif %} {{sp}} {% endfor %} {% endmacro %} +{% macro allValuesBlock images prefix isLast sp %} +{{sp}} {% for image in images %} +{{sp}} {% if not image.items %} +{{sp}} {{prefix}}{{image.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}{% if not forloop.last or not isLast %},{% endif %} +{{sp}} {% else %} +{{sp}} {% set prefix2 %}{{prefix}}{{image.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}.{% endset %} +{{sp}} {% call allValuesBlock image.items prefix2 forloop.last sp %} +{{sp}} {% endif %} +{{sp}} {% endfor %} +{% endmacro %} // swiftlint:disable identifier_name line_length nesting type_body_length type_name enum {{enumName}} { {% if catalogs.count > 1 %} {% for catalog in catalogs %} enum {{catalog.name|swiftIdentifier|titlecase|snakeToCamelCase|escapeReservedKeywords}} { - {% call recursiveBlock catalog.assets " " %} + {% call enumBlock catalog.assets " " %} } {% endfor %} {% else %} - {% call recursiveBlock catalogs.first.assets "" %} + {% call enumBlock catalogs.first.assets "" %} {% endif %} } // swiftlint:enable identifier_name line_length nesting type_body_length type_name diff --git a/templates/images/swift3.stencil b/templates/images/swift3.stencil index c96ac37..fe728d1 100644 --- a/templates/images/swift3.stencil +++ b/templates/images/swift3.stencil @@ -40,29 +40,47 @@ struct {{enumName}}Type: ExpressibleByStringLiteral { self.init(stringLiteral: value) } } -{% macro recursiveBlock images sp %} +{% macro enumBlock images sp %} +{{sp}} {% call casesBlock images sp %} + +{{sp}} static let allValues = [ +{{sp}} {% set sp2 %}{{sp}} {% endset %} +{{sp}} {% call allValuesBlock images "" false sp2 %} +{{sp}} ] +{% endmacro %} +{% macro casesBlock images sp %} {{sp}} {% for image in images %} {{sp}} {% if not image.items %} {{sp}} static let {{image.name|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}}: {{enumName}}Type = "{{image.value}}" {{sp}} {% else %} {{sp}} enum {{image.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}} { {{sp}} {% set sp2 %}{{sp}} {% endset %} -{{sp}} {% call recursiveBlock image.items sp2 %} +{{sp}} {% call casesBlock image.items sp2 %} {{sp}} } {{sp}} {% endif %} {{sp}} {% endfor %} {% endmacro %} +{% macro allValuesBlock images prefix isLast sp %} +{{sp}} {% for image in images %} +{{sp}} {% if not image.items %} +{{sp}} {{prefix}}{{image.name|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}}{% if not forloop.last or not isLast %},{% endif %} +{{sp}} {% else %} +{{sp}} {% set prefix2 %}{{prefix}}{{image.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}.{% endset %} +{{sp}} {% call allValuesBlock image.items prefix2 forloop.last sp %} +{{sp}} {% endif %} +{{sp}} {% endfor %} +{% endmacro %} // swiftlint:disable identifier_name line_length nesting type_body_length type_name enum {{enumName}} { {% if catalogs.count > 1 %} {% for catalog in catalogs %} enum {{catalog.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}} { - {% call recursiveBlock catalog.assets " " %} + {% call enumBlock catalog.assets " " %} } {% endfor %} {% else %} - {% call recursiveBlock catalogs.first.assets "" %} + {% call enumBlock catalogs.first.assets "" %} {% endif %} } // swiftlint:enable identifier_name line_length nesting type_body_length type_name From 6e747277f0c3e413f82a1c5e6cfc120bf7a1c9ba Mon Sep 17 00:00:00 2001 From: David Jennes Date: Thu, 11 May 2017 23:35:52 +0200 Subject: [PATCH 05/12] Add a `noComments` parameter to the string templates --- ...-swift2-context-defaults-no-comments.swift | 86 +++++++++++++++++++ ...-swift3-context-defaults-no-comments.swift | 86 +++++++++++++++++++ ...-swift2-context-defaults-no-comments.swift | 63 ++++++++++++++ ...-swift3-context-defaults-no-comments.swift | 63 ++++++++++++++ Tests/TemplatesTests/StringsTests.swift | 5 +- templates/strings/dot-syntax-swift2.stencil | 2 + templates/strings/dot-syntax-swift3.stencil | 2 + templates/strings/flat-swift2.stencil | 2 + templates/strings/flat-swift3.stencil | 2 + 9 files changed, 310 insertions(+), 1 deletion(-) create mode 100644 Tests/Expected/Strings/dot-syntax-swift2-context-defaults-no-comments.swift create mode 100644 Tests/Expected/Strings/dot-syntax-swift3-context-defaults-no-comments.swift create mode 100644 Tests/Expected/Strings/flat-swift2-context-defaults-no-comments.swift create mode 100644 Tests/Expected/Strings/flat-swift3-context-defaults-no-comments.swift diff --git a/Tests/Expected/Strings/dot-syntax-swift2-context-defaults-no-comments.swift b/Tests/Expected/Strings/dot-syntax-swift2-context-defaults-no-comments.swift new file mode 100644 index 0000000..83a622c --- /dev/null +++ b/Tests/Expected/Strings/dot-syntax-swift2-context-defaults-no-comments.swift @@ -0,0 +1,86 @@ +// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen + +import Foundation + +// swiftlint:disable file_length + +// swiftlint:disable explicit_type_interface identifier_name line_length nesting type_body_length type_name +enum L10n { + static let AlertMessage = L10n.tr("alert_message") + static let AlertTitle = L10n.tr("alert_title") + static func ObjectOwnership(p1: Int, p2: String, p3: String) -> String { + return L10n.tr("ObjectOwnership", p1, p2, p3) + } + static func Private(p1: String, p2: Int) -> String { + return L10n.tr("private", p1, p2) + } + + enum Apples { + static func Count(p1: Int) -> String { + return L10n.tr("apples.count", p1) + } + } + + enum Bananas { + static func Owner(p1: Int, p2: String) -> String { + return L10n.tr("bananas.owner", p1, p2) + } + } + + enum Settings { + + enum NavigationBar { + static let `Self` = L10n.tr("settings.navigation-bar.self") + + enum Title { + + enum Deeper { + + enum Than { + + enum We { + + enum Can { + + enum Handle { + + enum No { + + enum Really { + + enum This { + + enum Is { + static let Deep = L10n.tr("settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") + } + } + } + } + } + } + } + } + } + + enum Even { + static let Deeper = L10n.tr("settings.navigation-bar.title.even.deeper") + } + } + } + + enum UserProfileSection { + static let FooterText = L10n.tr("seTTings.uSer-proFile-sectioN.footer_text") + static let HeaderTitle = L10n.tr("SETTINGS.USER_PROFILE_SECTION.HEADER_TITLE") + } + } +} +// swiftlint:enable explicit_type_interface identifier_name line_length nesting type_body_length type_name + +extension L10n { + private static func tr(key: String, _ args: CVarArgType...) -> String { + let format = NSLocalizedString(key, bundle: NSBundle(forClass: BundleToken.self), comment: "") + return String(format: format, locale: NSLocale.currentLocale(), arguments: args) + } +} + +private final class BundleToken {} diff --git a/Tests/Expected/Strings/dot-syntax-swift3-context-defaults-no-comments.swift b/Tests/Expected/Strings/dot-syntax-swift3-context-defaults-no-comments.swift new file mode 100644 index 0000000..6cdba1b --- /dev/null +++ b/Tests/Expected/Strings/dot-syntax-swift3-context-defaults-no-comments.swift @@ -0,0 +1,86 @@ +// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen + +import Foundation + +// swiftlint:disable file_length + +// swiftlint:disable explicit_type_interface identifier_name line_length nesting type_body_length type_name +enum L10n { + static let alertMessage = L10n.tr("alert_message") + static let alertTitle = L10n.tr("alert_title") + static func objectOwnership(_ p1: Int, _ p2: String, _ p3: String) -> String { + return L10n.tr("ObjectOwnership", p1, p2, p3) + } + static func `private`(_ p1: String, _ p2: Int) -> String { + return L10n.tr("private", p1, p2) + } + + enum Apples { + static func count(_ p1: Int) -> String { + return L10n.tr("apples.count", p1) + } + } + + enum Bananas { + static func owner(_ p1: Int, _ p2: String) -> String { + return L10n.tr("bananas.owner", p1, p2) + } + } + + enum Settings { + + enum NavigationBar { + static let `self` = L10n.tr("settings.navigation-bar.self") + + enum Title { + + enum Deeper { + + enum Than { + + enum We { + + enum Can { + + enum Handle { + + enum No { + + enum Really { + + enum This { + + enum Is { + static let deep = L10n.tr("settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") + } + } + } + } + } + } + } + } + } + + enum Even { + static let deeper = L10n.tr("settings.navigation-bar.title.even.deeper") + } + } + } + + enum UserProfileSection { + static let footerText = L10n.tr("seTTings.uSer-proFile-sectioN.footer_text") + static let headerTitle = L10n.tr("SETTINGS.USER_PROFILE_SECTION.HEADER_TITLE") + } + } +} +// swiftlint:enable explicit_type_interface identifier_name line_length nesting type_body_length type_name + +extension L10n { + fileprivate static func tr(_ key: String, _ args: CVarArg...) -> String { + let format = NSLocalizedString(key, bundle: Bundle(for: BundleToken.self), comment: "") + return String(format: format, locale: Locale.current, arguments: args) + } +} + +private final class BundleToken {} diff --git a/Tests/Expected/Strings/flat-swift2-context-defaults-no-comments.swift b/Tests/Expected/Strings/flat-swift2-context-defaults-no-comments.swift new file mode 100644 index 0000000..99966b6 --- /dev/null +++ b/Tests/Expected/Strings/flat-swift2-context-defaults-no-comments.swift @@ -0,0 +1,63 @@ +// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen + +import Foundation + +// swiftlint:disable file_length + +// swiftlint:disable identifier_name line_length type_body_length +enum L10n { + case AlertMessage + case AlertTitle + case ObjectOwnership(Int, String, String) + case Private(String, Int) + case ApplesCount(Int) + case BananasOwner(Int, String) + case SettingsNavigationBarSelf + case SettingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep + case SettingsNavigationBarTitleEvenDeeper + case SeTTingsUSerProFileSectioNFooterText + case SettingsUserProfileSectionHeaderTitle +} + +extension L10n: CustomStringConvertible { + var description: String { return self.string } + + var string: String { + switch self { + case .AlertMessage: + return L10n.tr("alert_message") + case .AlertTitle: + return L10n.tr("alert_title") + case .ObjectOwnership(let p1, let p2, let p3): + return L10n.tr("ObjectOwnership", p1, p2, p3) + case .Private(let p1, let p2): + return L10n.tr("private", p1, p2) + case .ApplesCount(let p1): + return L10n.tr("apples.count", p1) + case .BananasOwner(let p1, let p2): + return L10n.tr("bananas.owner", p1, p2) + case .SettingsNavigationBarSelf: + return L10n.tr("settings.navigation-bar.self") + case .SettingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep: + return L10n.tr("settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") + case .SettingsNavigationBarTitleEvenDeeper: + return L10n.tr("settings.navigation-bar.title.even.deeper") + case .SeTTingsUSerProFileSectioNFooterText: + return L10n.tr("seTTings.uSer-proFile-sectioN.footer_text") + case .SettingsUserProfileSectionHeaderTitle: + return L10n.tr("SETTINGS.USER_PROFILE_SECTION.HEADER_TITLE") + } + } + + private static func tr(key: String, _ args: CVarArgType...) -> String { + let format = NSLocalizedString(key, bundle: NSBundle(forClass: BundleToken.self), comment: "") + return String(format: format, locale: NSLocale.currentLocale(), arguments: args) + } +} +// swiftlint:enable identifier_name line_length type_body_length + +func tr(key: L10n) -> String { + return key.string +} + +private final class BundleToken {} diff --git a/Tests/Expected/Strings/flat-swift3-context-defaults-no-comments.swift b/Tests/Expected/Strings/flat-swift3-context-defaults-no-comments.swift new file mode 100644 index 0000000..0ec798b --- /dev/null +++ b/Tests/Expected/Strings/flat-swift3-context-defaults-no-comments.swift @@ -0,0 +1,63 @@ +// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen + +import Foundation + +// swiftlint:disable file_length + +// swiftlint:disable identifier_name line_length type_body_length +enum L10n { + case alertMessage + case alertTitle + case objectOwnership(Int, String, String) + case `private`(String, Int) + case applesCount(Int) + case bananasOwner(Int, String) + case settingsNavigationBarSelf + case settingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep + case settingsNavigationBarTitleEvenDeeper + case seTTingsUSerProFileSectioNFooterText + case settingsUserProfileSectionHeaderTitle +} + +extension L10n: CustomStringConvertible { + var description: String { return self.string } + + var string: String { + switch self { + case .alertMessage: + return L10n.tr(key: "alert_message") + case .alertTitle: + return L10n.tr(key: "alert_title") + case .objectOwnership(let p1, let p2, let p3): + return L10n.tr(key: "ObjectOwnership", p1, p2, p3) + case .`private`(let p1, let p2): + return L10n.tr(key: "private", p1, p2) + case .applesCount(let p1): + return L10n.tr(key: "apples.count", p1) + case .bananasOwner(let p1, let p2): + return L10n.tr(key: "bananas.owner", p1, p2) + case .settingsNavigationBarSelf: + return L10n.tr(key: "settings.navigation-bar.self") + case .settingsNavigationBarTitleDeeperThanWeCanHandleNoReallyThisIsDeep: + return L10n.tr(key: "settings.navigation-bar.title.deeper.than.we.can.handle.no.really.this.is.deep") + case .settingsNavigationBarTitleEvenDeeper: + return L10n.tr(key: "settings.navigation-bar.title.even.deeper") + case .seTTingsUSerProFileSectioNFooterText: + return L10n.tr(key: "seTTings.uSer-proFile-sectioN.footer_text") + case .settingsUserProfileSectionHeaderTitle: + return L10n.tr(key: "SETTINGS.USER_PROFILE_SECTION.HEADER_TITLE") + } + } + + private static func tr(key: String, _ args: CVarArg...) -> String { + let format = NSLocalizedString(key, bundle: Bundle(for: BundleToken.self), comment: "") + return String(format: format, locale: Locale.current, arguments: args) + } +} +// swiftlint:enable identifier_name line_length type_body_length + +func tr(_ key: L10n) -> String { + return key.string +} + +private final class BundleToken {} diff --git a/Tests/TemplatesTests/StringsTests.swift b/Tests/TemplatesTests/StringsTests.swift index 305b928..da0b50c 100644 --- a/Tests/TemplatesTests/StringsTests.swift +++ b/Tests/TemplatesTests/StringsTests.swift @@ -21,7 +21,10 @@ class StringsTests: XCTestCase { suffix: ""), (context: try StencilContext.enrich(context: context, parameters: ["enumName=XCTLoc"]), - suffix: "-customname") + suffix: "-customname"), + (context: try StencilContext.enrich(context: context, + parameters: ["noComments"]), + suffix: "-no-comments") ] } diff --git a/templates/strings/dot-syntax-swift2.stencil b/templates/strings/dot-syntax-swift2.stencil index 94f549d..1b202b1 100644 --- a/templates/strings/dot-syntax-swift2.stencil +++ b/templates/strings/dot-syntax-swift2.stencil @@ -8,7 +8,9 @@ import Foundation {% macro argumentsBlock types %}{% for type in types %}p{{forloop.counter}}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %} {% macro recursiveBlock item sp %} {{sp}} {% for string in item.strings %} +{{sp}} {% if not param.noComments %} {{sp}} /// {{string.translation}} +{{sp}} {% endif %} {{sp}} {% if string.types %} {{sp}} static func {{string.name|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}({% call parametersBlock string.types %}) -> String { {{sp}} return {{enumName}}.tr("{{string.key}}", {% call argumentsBlock string.types %}) diff --git a/templates/strings/dot-syntax-swift3.stencil b/templates/strings/dot-syntax-swift3.stencil index 1e7cc49..926b37f 100644 --- a/templates/strings/dot-syntax-swift3.stencil +++ b/templates/strings/dot-syntax-swift3.stencil @@ -8,7 +8,9 @@ import Foundation {% macro argumentsBlock types %}{% for type in types %}p{{forloop.counter}}{% if not forloop.last %}, {% endif %}{% endfor %}{% endmacro %} {% macro recursiveBlock item sp %} {{sp}} {% for string in item.strings %} +{{sp}} {% if not param.noComments %} {{sp}} /// {{string.translation}} +{{sp}} {% endif %} {{sp}} {% if string.types %} {{sp}} static func {{string.name|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}}({% call parametersBlock string.types %}) -> String { {{sp}} return {{enumName}}.tr("{{string.key}}", {% call argumentsBlock string.types %}) diff --git a/templates/strings/flat-swift2.stencil b/templates/strings/flat-swift2.stencil index c42e5f2..f6f4aa5 100644 --- a/templates/strings/flat-swift2.stencil +++ b/templates/strings/flat-swift2.stencil @@ -6,7 +6,9 @@ import Foundation // swiftlint:disable file_length {% macro recursiveBlock item %} {% for string in item.strings %} + {% if not param.noComments %} /// {{string.translation}} + {% endif %} case {{string.key|swiftIdentifier|snakeToCamelCase|escapeReservedKeywords}}{% if string.types %}({{string.types|join:", "}}){% endif %} {% endfor %} {% for child in item.children %} diff --git a/templates/strings/flat-swift3.stencil b/templates/strings/flat-swift3.stencil index 59fa753..f72e85b 100644 --- a/templates/strings/flat-swift3.stencil +++ b/templates/strings/flat-swift3.stencil @@ -6,7 +6,9 @@ import Foundation // swiftlint:disable file_length {% macro recursiveBlock item %} {% for string in item.strings %} + {% if not param.noComments %} /// {{string.translation}} + {% endif %} case {{string.key|swiftIdentifier|snakeToCamelCase|lowerFirstWord|escapeReservedKeywords}}{% if string.types %}({{string.types|join:", "}}){% endif %} {% endfor %} {% for child in item.children %} From 18efcdb8cdaaa05ab5962b5be15aa4c0eb972643 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Fri, 12 May 2017 00:18:08 +0200 Subject: [PATCH 06/12] work a bit on documentation --- Documentation/colors/rawvalue.md | 54 ------------------- .../colors/{default.md => swift2.md} | 6 +-- Documentation/colors/swift3.md | 2 +- Documentation/fonts/{default.md => swift2.md} | 6 +-- Documentation/fonts/swift3.md | 2 +- .../images/{dot-syntax.md => swift2.md} | 6 +-- .../{dot-syntax-swift3.md => swift3.md} | 6 +-- .../{osx-default.md => osx-swift2.md} | 6 +-- Documentation/storyboards/osx-swift3.md | 4 +- .../storyboards/{default.md => swift2.md} | 6 +-- Documentation/storyboards/swift3.md | 2 +- .../{dot-syntax.md => dot-syntax-swift2.md} | 6 +-- Documentation/strings/dot-syntax-swift3.md | 4 +- .../strings/{default.md => flat-swift2.md} | 6 +-- .../strings/{swift3.md => flat-swift3.md} | 4 +- 15 files changed, 33 insertions(+), 87 deletions(-) delete mode 100644 Documentation/colors/rawvalue.md rename Documentation/colors/{default.md => swift2.md} (90%) rename Documentation/fonts/{default.md => swift2.md} (89%) rename Documentation/images/{dot-syntax.md => swift2.md} (89%) rename Documentation/images/{dot-syntax-swift3.md => swift3.md} (88%) rename Documentation/storyboards/{osx-default.md => osx-swift2.md} (93%) rename Documentation/storyboards/{default.md => swift2.md} (93%) rename Documentation/strings/{dot-syntax.md => dot-syntax-swift2.md} (89%) rename Documentation/strings/{default.md => flat-swift2.md} (88%) rename Documentation/strings/{swift3.md => flat-swift3.md} (93%) diff --git a/Documentation/colors/rawvalue.md b/Documentation/colors/rawvalue.md deleted file mode 100644 index 693bac9..0000000 --- a/Documentation/colors/rawvalue.md +++ /dev/null @@ -1,54 +0,0 @@ -⚠️ Deprecated template ⚠️ - -## Template Information - -| Name | Description | -| --------- | ----------------- | -| File name | colors-rawvalue.stencil | -| Invocation example | `swiftgen colors -t rawvalue …` | -| Language | Swift 2 | -| Author | Olivier Halligon | - -## When to use it - -- When you need to generate *Swift 2* code -- When you DON'T have _multiple_ color names with the _same_ value - -In contrast to the default colors template, this template generates an enum conforming to the RawRepresentable protocol. Each enum case has, as a value, the 32-bit integer representation of the color. - -## Customization - -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` - -| Parameter Name | Default Value | Description | -| -------------- | ------------- | ----------- | -| `enumName` | `ColorName` | Allows you to change the name of the generated `enum` containing all colors. | - -## Generated Code - -**Extract:** - -```swift -enum ColorName: UInt32 { - /// - /// Alpha: 100%
(0x339666ff) - case ArticleBody = 0x339666ff - /// - /// Alpha: 100%
(0xff66ccff) - case ArticleFootnote = 0xff66ccff -} -``` - -[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Colors/default-context-defaults.swift) - -## Usage example - -```swift -// You can create colors with the convenience constructor like this: -let title = UIColor(named: .ArticleTitle) -let footnote = UIColor(named: .ArticleFootnote) - -// Or as an alternative, you can refer to enum instance and call .color on it: -let sameTitle = ColorName.ArticleBody.color -let sameFootnote = ColorName.ArticleFootnote.color -``` diff --git a/Documentation/colors/default.md b/Documentation/colors/swift2.md similarity index 90% rename from Documentation/colors/default.md rename to Documentation/colors/swift2.md index 374a35a..e2e1be1 100644 --- a/Documentation/colors/default.md +++ b/Documentation/colors/swift2.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | colors-default.stencil | -| Invocation example | `swiftgen colors -t default …` | +| File name | colors/swift2.stencil | +| Invocation example | `swiftgen colors -t swift2 …` | | Language | Swift 2 | | Author | Olivier Halligon | @@ -35,7 +35,7 @@ enum ColorName { } ``` -[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Colors/default-context-defaults.swift) +[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Colors/swift2-context-defaults.swift) ## Usage example diff --git a/Documentation/colors/swift3.md b/Documentation/colors/swift3.md index d52f0d7..82dd17a 100644 --- a/Documentation/colors/swift3.md +++ b/Documentation/colors/swift3.md @@ -2,7 +2,7 @@ | Name | Description | | --------- | ----------------- | -| File name | colors-swift3.stencil | +| File name | colors/swift3.stencil | | Invocation example | `swiftgen colors -t swift3 …` | | Language | Swift 3 | | Author | Olivier Halligon | diff --git a/Documentation/fonts/default.md b/Documentation/fonts/swift2.md similarity index 89% rename from Documentation/fonts/default.md rename to Documentation/fonts/swift2.md index 98c6759..d2322a2 100644 --- a/Documentation/fonts/default.md +++ b/Documentation/fonts/swift2.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | fonts-default.stencil | -| Invocation example | `swiftgen fonts -t default …` | +| File name | fonts/swift2.stencil | +| Invocation example | `swiftgen fonts -t swift2 …` | | Language | Swift 2 | | Author | Olivier Halligon | @@ -34,7 +34,7 @@ enum FontFamily { } ``` -[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Fonts/default-context-defaults.swift) +[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Fonts/swift2-context-defaults.swift) ## Usage example diff --git a/Documentation/fonts/swift3.md b/Documentation/fonts/swift3.md index 1bae079..3e42826 100644 --- a/Documentation/fonts/swift3.md +++ b/Documentation/fonts/swift3.md @@ -2,7 +2,7 @@ | Name | Description | | --------- | ----------------- | -| File name | fonts-swift3.stencil | +| File name | fonts/swift3.stencil | | Invocation example | `swiftgen fonts -t swift3 …` | | Language | Swift 3 | | Author | Olivier Halligon | diff --git a/Documentation/images/dot-syntax.md b/Documentation/images/swift2.md similarity index 89% rename from Documentation/images/dot-syntax.md rename to Documentation/images/swift2.md index b422b98..2503af2 100644 --- a/Documentation/images/dot-syntax.md +++ b/Documentation/images/swift2.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | images-dot-syntax.stencil | -| Invocation example | `swiftgen images -t dot-syntax …` | +| File name | images/swift2.stencil | +| Invocation example | `swiftgen images -t swift2 …` | | Language | Swift 2 | | Author | Olivier Halligon | @@ -35,7 +35,7 @@ enum Asset { } ``` -[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Images/dot-syntax-context-defaults.swift) +[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Images/swift2-context-defaults.swift) ## Usage example diff --git a/Documentation/images/dot-syntax-swift3.md b/Documentation/images/swift3.md similarity index 88% rename from Documentation/images/dot-syntax-swift3.md rename to Documentation/images/swift3.md index b286800..3e41b10 100644 --- a/Documentation/images/dot-syntax-swift3.md +++ b/Documentation/images/swift3.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | images-dot-syntax-swift3.stencil | -| Invocation example | `swiftgen images -t dot-syntax-swift3 …` | +| File name | images/swift3.stencil | +| Invocation example | `swiftgen images -t swift3 …` | | Language | Swift 3 | | Author | Olivier Halligon | @@ -35,7 +35,7 @@ enum Asset { } ``` -[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Images/dot-syntax-swift3-context-defaults.swift) +[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Images/swift3-context-defaults.swift) ## Usage example diff --git a/Documentation/storyboards/osx-default.md b/Documentation/storyboards/osx-swift2.md similarity index 93% rename from Documentation/storyboards/osx-default.md rename to Documentation/storyboards/osx-swift2.md index 66736bb..fde4aa5 100644 --- a/Documentation/storyboards/osx-default.md +++ b/Documentation/storyboards/osx-swift2.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | storyboards-osx-default.stencil | -| Invocation example | `swiftgen storyboards -t osx-default …` | +| File name | storyboards/macOS-swift2.stencil | +| Invocation example | `swiftgen storyboards -t macOS-swift2 …` | | Language | Swift 2 | | Author | Olivier Halligon | @@ -60,7 +60,7 @@ enum StoryboardSegue { } ``` -[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Storyboards-macOS/default-context-all.swift) +[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Storyboards-macOS/swift2-context-all.swift) ## Usage example diff --git a/Documentation/storyboards/osx-swift3.md b/Documentation/storyboards/osx-swift3.md index b9a72d9..d0600ae 100644 --- a/Documentation/storyboards/osx-swift3.md +++ b/Documentation/storyboards/osx-swift3.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | storyboards-osx-swift3.stencil | -| Invocation example | `swiftgen storyboards -t osx-swift3 …` | +| File name | storyboards/macOS-swift3.stencil | +| Invocation example | `swiftgen storyboards -t macOS-swift3 …` | | Language | Swift 3 | | Author | Olivier Halligon | diff --git a/Documentation/storyboards/default.md b/Documentation/storyboards/swift2.md similarity index 93% rename from Documentation/storyboards/default.md rename to Documentation/storyboards/swift2.md index c7d7f6e..3728e82 100644 --- a/Documentation/storyboards/default.md +++ b/Documentation/storyboards/swift2.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | storyboards-default.stencil | -| Invocation example | `swiftgen storyboards -t default …` | +| File name | storyboards/swift2.stencil | +| Invocation example | `swiftgen storyboards -t swift2 …` | | Language | Swift 2 | | Author | Olivier Halligon | @@ -56,7 +56,7 @@ enum StoryboardSegue { } ``` -[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Storyboards-iOS/default-context-all.swift) +[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Storyboards-iOS/swift2-context-all.swift) ## Usage example diff --git a/Documentation/storyboards/swift3.md b/Documentation/storyboards/swift3.md index c4b88f4..cc29829 100644 --- a/Documentation/storyboards/swift3.md +++ b/Documentation/storyboards/swift3.md @@ -2,7 +2,7 @@ | Name | Description | | --------- | ----------------- | -| File name | storyboards-swift3.stencil | +| File name | storyboards/swift3.stencil | | Invocation example | `swiftgen storyboards -t swift3 …` | | Language | Swift 3 | | Author | Olivier Halligon | diff --git a/Documentation/strings/dot-syntax.md b/Documentation/strings/dot-syntax-swift2.md similarity index 89% rename from Documentation/strings/dot-syntax.md rename to Documentation/strings/dot-syntax-swift2.md index 6aef412..ac5343a 100644 --- a/Documentation/strings/dot-syntax.md +++ b/Documentation/strings/dot-syntax-swift2.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | strings-dot-syntax.stencil | -| Invocation example | `swiftgen strings -t dot-syntax …` | +| File name | strings/dot-syntax-swift2.stencil | +| Invocation example | `swiftgen strings -t dot-syntax-swift2 …` | | Language | Swift 2 | | Author | Olivier Halligon | @@ -53,7 +53,7 @@ enum L10n { } ``` -[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Strings/dot-syntax-context-defaults.swift) +[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Strings/dot-syntax-swift2-context-defaults.swift) ## Usage example diff --git a/Documentation/strings/dot-syntax-swift3.md b/Documentation/strings/dot-syntax-swift3.md index 8b908b3..651a088 100644 --- a/Documentation/strings/dot-syntax-swift3.md +++ b/Documentation/strings/dot-syntax-swift3.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | strings-dot-syntax.stencil | -| Invocation example | `swiftgen strings -t dot-syntax …` | +| File name | strings/dot-syntax-swift3.stencil | +| Invocation example | `swiftgen strings -t dot-syntax-swift3 …` | | Language | Swift 3 | | Author | Olivier Halligon | diff --git a/Documentation/strings/default.md b/Documentation/strings/flat-swift2.md similarity index 88% rename from Documentation/strings/default.md rename to Documentation/strings/flat-swift2.md index ad16ff7..7fee3aa 100644 --- a/Documentation/strings/default.md +++ b/Documentation/strings/flat-swift2.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | strings-default.stencil | -| Invocation example | `swiftgen strings -t default …` | +| File name | strings/flat-swift2.stencil | +| Invocation example | `swiftgen strings -t flat-swift2 …` | | Language | Swift 2 | | Author | Olivier Halligon | @@ -37,7 +37,7 @@ enum L10n { } ``` -[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Strings/default-context-defaults.swift) +[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Strings/flat-swift2-context-defaults.swift) ## Usage example diff --git a/Documentation/strings/swift3.md b/Documentation/strings/flat-swift3.md similarity index 93% rename from Documentation/strings/swift3.md rename to Documentation/strings/flat-swift3.md index f918d4f..34fbb5a 100644 --- a/Documentation/strings/swift3.md +++ b/Documentation/strings/flat-swift3.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | strings-swift3.stencil | -| Invocation example | `swiftgen strings -t swift3 …` | +| File name | strings/flat-swift3.stencil | +| Invocation example | `swiftgen strings -t flat-swift3 …` | | Language | Swift 3 | | Author | Olivier Halligon | From 9926d29eb416d88ac7e3c42a60a6e5d1186215a1 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Fri, 12 May 2017 14:45:45 +0200 Subject: [PATCH 07/12] strings: rename dot-syntax to structured, to better contrast with `flat` templates --- ...dot-syntax-swift2.md => structured-swift2.md} | 8 ++++---- ...dot-syntax-swift3.md => structured-swift3.md} | 8 ++++---- ...red-swift2-context-defaults-customname.swift} | 0 ...ed-swift2-context-defaults-no-comments.swift} | 0 ... => structured-swift2-context-defaults.swift} | 0 ...ift => structured-swift2-context-empty.swift} | 0 ...red-swift3-context-defaults-customname.swift} | 0 ...ed-swift3-context-defaults-no-comments.swift} | 0 ... => structured-swift3-context-defaults.swift} | 0 ...ift => structured-swift3-context-empty.swift} | 0 Tests/TemplatesTests/StringsTests.swift | 16 ++++++++-------- ...-swift2.stencil => structured-swift2.stencil} | 0 ...-swift3.stencil => structured-swift3.stencil} | 0 13 files changed, 16 insertions(+), 16 deletions(-) rename Documentation/strings/{dot-syntax-swift2.md => structured-swift2.md} (87%) rename Documentation/strings/{dot-syntax-swift3.md => structured-swift3.md} (87%) rename Tests/Expected/Strings/{dot-syntax-swift2-context-defaults-customname.swift => structured-swift2-context-defaults-customname.swift} (100%) rename Tests/Expected/Strings/{dot-syntax-swift2-context-defaults-no-comments.swift => structured-swift2-context-defaults-no-comments.swift} (100%) rename Tests/Expected/Strings/{dot-syntax-swift2-context-defaults.swift => structured-swift2-context-defaults.swift} (100%) rename Tests/Expected/Strings/{dot-syntax-swift2-context-empty.swift => structured-swift2-context-empty.swift} (100%) rename Tests/Expected/Strings/{dot-syntax-swift3-context-defaults-customname.swift => structured-swift3-context-defaults-customname.swift} (100%) rename Tests/Expected/Strings/{dot-syntax-swift3-context-defaults-no-comments.swift => structured-swift3-context-defaults-no-comments.swift} (100%) rename Tests/Expected/Strings/{dot-syntax-swift3-context-defaults.swift => structured-swift3-context-defaults.swift} (100%) rename Tests/Expected/Strings/{dot-syntax-swift3-context-empty.swift => structured-swift3-context-empty.swift} (100%) rename templates/strings/{dot-syntax-swift2.stencil => structured-swift2.stencil} (100%) rename templates/strings/{dot-syntax-swift3.stencil => structured-swift3.stencil} (100%) diff --git a/Documentation/strings/dot-syntax-swift2.md b/Documentation/strings/structured-swift2.md similarity index 87% rename from Documentation/strings/dot-syntax-swift2.md rename to Documentation/strings/structured-swift2.md index ac5343a..1ea2ab8 100644 --- a/Documentation/strings/dot-syntax-swift2.md +++ b/Documentation/strings/structured-swift2.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | strings/dot-syntax-swift2.stencil | -| Invocation example | `swiftgen strings -t dot-syntax-swift2 …` | +| File name | strings/structured-swift2.stencil | +| Invocation example | `swiftgen strings -t structured-swift2 …` | | Language | Swift 2 | | Author | Olivier Halligon | @@ -20,7 +20,7 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | @@ -53,7 +53,7 @@ enum L10n { } ``` -[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Strings/dot-syntax-swift2-context-defaults.swift) +[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Strings/structured-swift2-context-defaults.swift) ## Usage example diff --git a/Documentation/strings/dot-syntax-swift3.md b/Documentation/strings/structured-swift3.md similarity index 87% rename from Documentation/strings/dot-syntax-swift3.md rename to Documentation/strings/structured-swift3.md index 651a088..9306df4 100644 --- a/Documentation/strings/dot-syntax-swift3.md +++ b/Documentation/strings/structured-swift3.md @@ -2,8 +2,8 @@ | Name | Description | | --------- | ----------------- | -| File name | strings/dot-syntax-swift3.stencil | -| Invocation example | `swiftgen strings -t dot-syntax-swift3 …` | +| File name | strings/structured-swift3.stencil | +| Invocation example | `swiftgen strings -t structured-swift3 …` | | Language | Swift 3 | | Author | Olivier Halligon | @@ -20,7 +20,7 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | @@ -53,7 +53,7 @@ enum L10n { } ``` -[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Strings/dot-syntax-swift3-context-defaults.swift) +[Full generated code](https://github.com/SwiftGen/templates/blob/master/Tests/Expected/Strings/structured-swift3-context-defaults.swift) ## Usage example diff --git a/Tests/Expected/Strings/dot-syntax-swift2-context-defaults-customname.swift b/Tests/Expected/Strings/structured-swift2-context-defaults-customname.swift similarity index 100% rename from Tests/Expected/Strings/dot-syntax-swift2-context-defaults-customname.swift rename to Tests/Expected/Strings/structured-swift2-context-defaults-customname.swift diff --git a/Tests/Expected/Strings/dot-syntax-swift2-context-defaults-no-comments.swift b/Tests/Expected/Strings/structured-swift2-context-defaults-no-comments.swift similarity index 100% rename from Tests/Expected/Strings/dot-syntax-swift2-context-defaults-no-comments.swift rename to Tests/Expected/Strings/structured-swift2-context-defaults-no-comments.swift diff --git a/Tests/Expected/Strings/dot-syntax-swift2-context-defaults.swift b/Tests/Expected/Strings/structured-swift2-context-defaults.swift similarity index 100% rename from Tests/Expected/Strings/dot-syntax-swift2-context-defaults.swift rename to Tests/Expected/Strings/structured-swift2-context-defaults.swift diff --git a/Tests/Expected/Strings/dot-syntax-swift2-context-empty.swift b/Tests/Expected/Strings/structured-swift2-context-empty.swift similarity index 100% rename from Tests/Expected/Strings/dot-syntax-swift2-context-empty.swift rename to Tests/Expected/Strings/structured-swift2-context-empty.swift diff --git a/Tests/Expected/Strings/dot-syntax-swift3-context-defaults-customname.swift b/Tests/Expected/Strings/structured-swift3-context-defaults-customname.swift similarity index 100% rename from Tests/Expected/Strings/dot-syntax-swift3-context-defaults-customname.swift rename to Tests/Expected/Strings/structured-swift3-context-defaults-customname.swift diff --git a/Tests/Expected/Strings/dot-syntax-swift3-context-defaults-no-comments.swift b/Tests/Expected/Strings/structured-swift3-context-defaults-no-comments.swift similarity index 100% rename from Tests/Expected/Strings/dot-syntax-swift3-context-defaults-no-comments.swift rename to Tests/Expected/Strings/structured-swift3-context-defaults-no-comments.swift diff --git a/Tests/Expected/Strings/dot-syntax-swift3-context-defaults.swift b/Tests/Expected/Strings/structured-swift3-context-defaults.swift similarity index 100% rename from Tests/Expected/Strings/dot-syntax-swift3-context-defaults.swift rename to Tests/Expected/Strings/structured-swift3-context-defaults.swift diff --git a/Tests/Expected/Strings/dot-syntax-swift3-context-empty.swift b/Tests/Expected/Strings/structured-swift3-context-empty.swift similarity index 100% rename from Tests/Expected/Strings/dot-syntax-swift3-context-empty.swift rename to Tests/Expected/Strings/structured-swift3-context-empty.swift diff --git a/Tests/TemplatesTests/StringsTests.swift b/Tests/TemplatesTests/StringsTests.swift index da0b50c..6215347 100644 --- a/Tests/TemplatesTests/StringsTests.swift +++ b/Tests/TemplatesTests/StringsTests.swift @@ -28,29 +28,29 @@ class StringsTests: XCTestCase { ] } - func testDotSyntaxSwift2() { - test(template: "dot-syntax-swift2", + func testFlatSwift2() { + test(template: "flat-swift2", contextNames: Contexts.all, directory: .strings, contextVariations: variations) } - func testDotSyntaxSwift3() { - test(template: "dot-syntax-swift3", + func testFlatSwift3() { + test(template: "flat-swift3", contextNames: Contexts.all, directory: .strings, contextVariations: variations) } - func testFlatSwift2() { - test(template: "flat-swift2", + func testStructuredSwift2() { + test(template: "structured-swift2", contextNames: Contexts.all, directory: .strings, contextVariations: variations) } - func testFlatSwift3() { - test(template: "flat-swift3", + func testStructuredSwift3() { + test(template: "structured-swift3", contextNames: Contexts.all, directory: .strings, contextVariations: variations) diff --git a/templates/strings/dot-syntax-swift2.stencil b/templates/strings/structured-swift2.stencil similarity index 100% rename from templates/strings/dot-syntax-swift2.stencil rename to templates/strings/structured-swift2.stencil diff --git a/templates/strings/dot-syntax-swift3.stencil b/templates/strings/structured-swift3.stencil similarity index 100% rename from templates/strings/dot-syntax-swift3.stencil rename to templates/strings/structured-swift3.stencil From 5630bc844ea491c2330d805b9bc8ef2b149d1f38 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Fri, 12 May 2017 14:54:30 +0200 Subject: [PATCH 08/12] Document the `noComments` parameter --- Documentation/colors/swift2.md | 2 +- Documentation/colors/swift3.md | 2 +- Documentation/fonts/swift2.md | 2 +- Documentation/fonts/swift3.md | 2 +- Documentation/images/swift2.md | 2 +- Documentation/images/swift3.md | 2 +- Documentation/storyboards/osx-swift2.md | 2 +- Documentation/storyboards/osx-swift3.md | 2 +- Documentation/storyboards/swift2.md | 2 +- Documentation/storyboards/swift3.md | 2 +- Documentation/strings/flat-swift2.md | 3 ++- Documentation/strings/flat-swift3.md | 3 ++- Documentation/strings/structured-swift2.md | 1 + Documentation/strings/structured-swift3.md | 1 + 14 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Documentation/colors/swift2.md b/Documentation/colors/swift2.md index e2e1be1..c166746 100644 --- a/Documentation/colors/swift2.md +++ b/Documentation/colors/swift2.md @@ -14,7 +14,7 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | diff --git a/Documentation/colors/swift3.md b/Documentation/colors/swift3.md index 82dd17a..85ed1d9 100644 --- a/Documentation/colors/swift3.md +++ b/Documentation/colors/swift3.md @@ -14,7 +14,7 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | diff --git a/Documentation/fonts/swift2.md b/Documentation/fonts/swift2.md index d2322a2..d70328c 100644 --- a/Documentation/fonts/swift2.md +++ b/Documentation/fonts/swift2.md @@ -13,7 +13,7 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | diff --git a/Documentation/fonts/swift3.md b/Documentation/fonts/swift3.md index 3e42826..ac84ec8 100644 --- a/Documentation/fonts/swift3.md +++ b/Documentation/fonts/swift3.md @@ -13,7 +13,7 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | diff --git a/Documentation/images/swift2.md b/Documentation/images/swift2.md index 2503af2..fb933c0 100644 --- a/Documentation/images/swift2.md +++ b/Documentation/images/swift2.md @@ -15,7 +15,7 @@ It also takes into account any namespacing folder in your Assets Catalogs (i.e. ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | diff --git a/Documentation/images/swift3.md b/Documentation/images/swift3.md index 3e41b10..b3cf402 100644 --- a/Documentation/images/swift3.md +++ b/Documentation/images/swift3.md @@ -15,7 +15,7 @@ It also takes into account any namespacing folder in your Assets Catalogs (i.e. ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | diff --git a/Documentation/storyboards/osx-swift2.md b/Documentation/storyboards/osx-swift2.md index fde4aa5..71b7e83 100644 --- a/Documentation/storyboards/osx-swift2.md +++ b/Documentation/storyboards/osx-swift2.md @@ -14,7 +14,7 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | diff --git a/Documentation/storyboards/osx-swift3.md b/Documentation/storyboards/osx-swift3.md index d0600ae..4b88b38 100644 --- a/Documentation/storyboards/osx-swift3.md +++ b/Documentation/storyboards/osx-swift3.md @@ -14,7 +14,7 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | diff --git a/Documentation/storyboards/swift2.md b/Documentation/storyboards/swift2.md index 3728e82..809be34 100644 --- a/Documentation/storyboards/swift2.md +++ b/Documentation/storyboards/swift2.md @@ -14,7 +14,7 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | diff --git a/Documentation/storyboards/swift3.md b/Documentation/storyboards/swift3.md index cc29829..035956d 100644 --- a/Documentation/storyboards/swift3.md +++ b/Documentation/storyboards/swift3.md @@ -14,7 +14,7 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | diff --git a/Documentation/strings/flat-swift2.md b/Documentation/strings/flat-swift2.md index 7fee3aa..48b61ca 100644 --- a/Documentation/strings/flat-swift2.md +++ b/Documentation/strings/flat-swift2.md @@ -14,11 +14,12 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | | `enumName` | `L10n` | Allows you to change the name of the generated `enum` containing all string tables. | +| `noComments` | N/A | Setting this parameter will disable the comments describing the translation of a key. | ## Generated Code diff --git a/Documentation/strings/flat-swift3.md b/Documentation/strings/flat-swift3.md index 34fbb5a..4309750 100644 --- a/Documentation/strings/flat-swift3.md +++ b/Documentation/strings/flat-swift3.md @@ -14,11 +14,12 @@ ## Customization -You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param ` +You can customize some elements of this template by overriding the following parameters when invoking `swiftgen` in the command line, using `--param =` | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | | `enumName` | `L10n` | Allows you to change the name of the generated `enum` containing all string tables. | +| `noComments` | N/A | Setting this parameter will disable the comments describing the translation of a key. | ## Generated Code diff --git a/Documentation/strings/structured-swift2.md b/Documentation/strings/structured-swift2.md index 1ea2ab8..3f5c5b0 100644 --- a/Documentation/strings/structured-swift2.md +++ b/Documentation/strings/structured-swift2.md @@ -25,6 +25,7 @@ You can customize some elements of this template by overriding the following par | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | | `enumName` | `L10n` | Allows you to change the name of the generated `enum` containing all string tables. | +| `noComments` | N/A | Setting this parameter will disable the comments describing the translation of a key. | ## Generated Code diff --git a/Documentation/strings/structured-swift3.md b/Documentation/strings/structured-swift3.md index 9306df4..00855d5 100644 --- a/Documentation/strings/structured-swift3.md +++ b/Documentation/strings/structured-swift3.md @@ -25,6 +25,7 @@ You can customize some elements of this template by overriding the following par | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | | `enumName` | `L10n` | Allows you to change the name of the generated `enum` containing all string tables. | +| `noComments` | N/A | Setting this parameter will disable the comments describing the translation of a key. | ## Generated Code From 98bacb5c6c75e8448273e8045bcf40089c2ec538 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Mon, 15 May 2017 14:27:58 +0200 Subject: [PATCH 09/12] Added migration guide --- Documentation/MigrationGuide.md | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/MigrationGuide.md diff --git a/Documentation/MigrationGuide.md b/Documentation/MigrationGuide.md new file mode 100644 index 0000000..9a41f20 --- /dev/null +++ b/Documentation/MigrationGuide.md @@ -0,0 +1,54 @@ +## Deprecated templates in 2.0 (SwiftGen 5.0) ## + +The two general themes for this version are: + +- Templates now reside in the subfolder corresponding to their subcommand (`colors`, `fonts`, ...) intead of the filename being prefixed with it. +- The `default` template doesn't exist anymore, templates now specify which swift version they support. + +Below is a list of renamed and removed templates, grouped by subcommand. If your template isn't listed, you don't need to do anything. + +### Colors ### + +| Old | New | Reason | +| --- | --- | ------ | +| default | swift2 | | +| rawvalues | **deleted** | Seldomly used | + +### Fonts ### + +| Old | New | Reason | +| --- | --- | ------ | +| default | swift2 | | + +### Images ### + +| Old | New | Reason | +| --- | --- | ------ | +| all-values | **deleted** | The other templates by default now generate an `allValues` static constant | +| default | **deleted** | Deprecated by `dot-syntax` (now called `swift2`) | +| dot-syntax | swift2 | | +| dot-syntax-swift3 | swift3 | | +| swift3 | **deleted** | Deprecated by `dot-syntax-swift3` (now called `swift3`) | + +### Storyboards ### + +| Old | New | Reason | +| --- | --- | ------ | +| default | swift2 | | +| lowercase | **deleted** | No longer needed since we prefix classes with their module | +| osx-default | macOS-swift2 | | +| osx-lowercase | **deleted** | No longer needed since we prefix classes with their module | +| osx-swift3 | macOS-swift3 | | +| uppercase | **deleted** | No longer needed since we prefix classes with their module | + +### Strings ### + +| Old | New | Reason | +| --- | --- | ------ | +| default | flat-swift2 | | +| dot-syntax | structured-swift2 | | +| dot-syntax-swift3 | structured-swift3 | | +| genstrings | **deleted** | Seldomly used | +| no-comments-swift3 | **deleted ** | The other templates now support a `noComments` parameter | +| structured | **deleted** | Deprecated by `dot-syntax` (now called `structured-swift2/3`) | +| swift3 | flat-swift3 | | From 1e8c057bcdbd6d1eb88963dcb25ac623b41b5a02 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Mon, 15 May 2017 14:56:50 +0200 Subject: [PATCH 10/12] Added a `noAllValues` parameter --- Documentation/images/swift2.md | 1 + Documentation/images/swift3.md | 1 + ...wift2-context-defaults-no-all-values.swift | 74 +++++++++++++++++++ ...wift3-context-defaults-no-all-values.swift | 74 +++++++++++++++++++ Tests/TemplatesTests/ImagesTests.swift | 5 +- templates/images/swift2.stencil | 2 + templates/images/swift3.stencil | 2 + 7 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 Tests/Expected/Images/swift2-context-defaults-no-all-values.swift create mode 100644 Tests/Expected/Images/swift3-context-defaults-no-all-values.swift diff --git a/Documentation/images/swift2.md b/Documentation/images/swift2.md index fb933c0..c3e18fb 100644 --- a/Documentation/images/swift2.md +++ b/Documentation/images/swift2.md @@ -20,6 +20,7 @@ You can customize some elements of this template by overriding the following par | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | | `enumName` | `Asset` | Allows you to change the name of the generated `enum` containing all image names. | +| `noAllValues` | N/A | Setting this parameter will disable generation of the `allValues` constant. | ## Generated Code diff --git a/Documentation/images/swift3.md b/Documentation/images/swift3.md index b3cf402..81e9cc6 100644 --- a/Documentation/images/swift3.md +++ b/Documentation/images/swift3.md @@ -20,6 +20,7 @@ You can customize some elements of this template by overriding the following par | Parameter Name | Default Value | Description | | -------------- | ------------- | ----------- | | `enumName` | `Asset` | Allows you to change the name of the generated `enum` containing all image names. | +| `noAllValues` | N/A | Setting this parameter will disable generation of the `allValues` constant. | ## Generated Code diff --git a/Tests/Expected/Images/swift2-context-defaults-no-all-values.swift b/Tests/Expected/Images/swift2-context-defaults-no-all-values.swift new file mode 100644 index 0000000..319dc74 --- /dev/null +++ b/Tests/Expected/Images/swift2-context-defaults-no-all-values.swift @@ -0,0 +1,74 @@ +// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen + +#if os(OSX) + import AppKit.NSImage + typealias Image = NSImage +#elseif os(iOS) || os(tvOS) || os(watchOS) + import UIKit.UIImage + typealias Image = UIImage +#endif + +// swiftlint:disable file_length + +struct AssetType: StringLiteralConvertible { + private var value: String + + var image: Image { + let bundle = NSBundle(forClass: BundleToken.self) + #if os(iOS) || os(tvOS) + let image = Image(named: value, inBundle: bundle, compatibleWithTraitCollection: nil) + #elseif os(OSX) + let image = bundle.imageForResource(value) + #elseif os(watchOS) + let image = Image(named: value) + #endif + guard let result = image else { fatalError("Unable to load image \(value).") } + return result + } + + init(stringLiteral value: String) { + self.value = value + } + + init(extendedGraphemeClusterLiteral value: String) { + self.init(stringLiteral: value) + } + + init(unicodeScalarLiteral value: String) { + self.init(stringLiteral: value) + } +} + +// swiftlint:disable identifier_name line_length nesting type_body_length type_name +enum Asset { + enum Exotic { + static let Banana: AssetType = "Exotic/Banana" + static let Mango: AssetType = "Exotic/Mango" + } + static let Private: AssetType = "private" + enum Round { + static let Apricot: AssetType = "Round/Apricot" + static let Orange: AssetType = "Round/Orange" + enum Red { + static let Apple: AssetType = "Round/Apple" + enum Double { + static let Cherry: AssetType = "Round/Double/Cherry" + } + static let Tomato: AssetType = "Round/Tomato" + } + } +} +// swiftlint:enable identifier_name line_length nesting type_body_length type_name + +extension Image { + convenience init!(asset: AssetType) { + #if os(iOS) || os(tvOS) + let bundle = NSBundle(forClass: BundleToken.self) + self.init(named: asset.value, inBundle: bundle, compatibleWithTraitCollection: nil) + #elseif os(OSX) || os(watchOS) + self.init(named: asset.value) + #endif + } +} + +private final class BundleToken {} diff --git a/Tests/Expected/Images/swift3-context-defaults-no-all-values.swift b/Tests/Expected/Images/swift3-context-defaults-no-all-values.swift new file mode 100644 index 0000000..781c301 --- /dev/null +++ b/Tests/Expected/Images/swift3-context-defaults-no-all-values.swift @@ -0,0 +1,74 @@ +// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen + +#if os(OSX) + import AppKit.NSImage + typealias Image = NSImage +#elseif os(iOS) || os(tvOS) || os(watchOS) + import UIKit.UIImage + typealias Image = UIImage +#endif + +// swiftlint:disable file_length + +struct AssetType: ExpressibleByStringLiteral { + fileprivate var value: String + + var image: Image { + let bundle = Bundle(for: BundleToken.self) + #if os(iOS) || os(tvOS) + let image = Image(named: value, in: bundle, compatibleWith: nil) + #elseif os(OSX) + let image = bundle.image(forResource: value) + #elseif os(watchOS) + let image = Image(named: value) + #endif + guard let result = image else { fatalError("Unable to load image \(value).") } + return result + } + + init(stringLiteral value: String) { + self.value = value + } + + init(extendedGraphemeClusterLiteral value: String) { + self.init(stringLiteral: value) + } + + init(unicodeScalarLiteral value: String) { + self.init(stringLiteral: value) + } +} + +// swiftlint:disable identifier_name line_length nesting type_body_length type_name +enum Asset { + enum Exotic { + static let banana: AssetType = "Exotic/Banana" + static let mango: AssetType = "Exotic/Mango" + } + static let `private`: AssetType = "private" + enum Round { + static let apricot: AssetType = "Round/Apricot" + static let orange: AssetType = "Round/Orange" + enum Red { + static let apple: AssetType = "Round/Apple" + enum Double { + static let cherry: AssetType = "Round/Double/Cherry" + } + static let tomato: AssetType = "Round/Tomato" + } + } +} +// swiftlint:enable identifier_name line_length nesting type_body_length type_name + +extension Image { + convenience init!(asset: AssetType) { + #if os(iOS) || os(tvOS) + let bundle = Bundle(for: BundleToken.self) + self.init(named: asset.value, in: bundle, compatibleWith: nil) + #elseif os(OSX) || os(watchOS) + self.init(named: asset.value) + #endif + } +} + +private final class BundleToken {} diff --git a/Tests/TemplatesTests/ImagesTests.swift b/Tests/TemplatesTests/ImagesTests.swift index c870511..49ed3c7 100644 --- a/Tests/TemplatesTests/ImagesTests.swift +++ b/Tests/TemplatesTests/ImagesTests.swift @@ -21,7 +21,10 @@ class ImagesTests: XCTestCase { suffix: ""), (context: try StencilContext.enrich(context: context, parameters: ["enumName=XCTImages"]), - suffix: "-customname") + suffix: "-customname"), + (context: try StencilContext.enrich(context: context, + parameters: ["noAllValues"]), + suffix: "-no-all-values") ] } diff --git a/templates/images/swift2.stencil b/templates/images/swift2.stencil index 786fe73..c6815d8 100644 --- a/templates/images/swift2.stencil +++ b/templates/images/swift2.stencil @@ -42,11 +42,13 @@ struct {{enumName}}Type: StringLiteralConvertible { } {% macro enumBlock images sp %} {{sp}} {% call casesBlock images sp %} +{{sp}} {% if not param.noAllValues %} {{sp}} static let allValues = [ {{sp}} {% set sp2 %}{{sp}} {% endset %} {{sp}} {% call allValuesBlock images "" false sp2 %} {{sp}} ] +{{sp}} {% endif %} {% endmacro %} {% macro casesBlock images sp %} {{sp}} {% for image in images %} diff --git a/templates/images/swift3.stencil b/templates/images/swift3.stencil index fe728d1..2bd3f35 100644 --- a/templates/images/swift3.stencil +++ b/templates/images/swift3.stencil @@ -42,11 +42,13 @@ struct {{enumName}}Type: ExpressibleByStringLiteral { } {% macro enumBlock images sp %} {{sp}} {% call casesBlock images sp %} +{{sp}} {% if not param.noAllValues %} {{sp}} static let allValues = [ {{sp}} {% set sp2 %}{{sp}} {% endset %} {{sp}} {% call allValuesBlock images "" false sp2 %} {{sp}} ] +{{sp}} {% endif %} {% endmacro %} {% macro casesBlock images sp %} {{sp}} {% for image in images %} From b80df018676f4b6e8a84cff572cf0dc1addfa47a Mon Sep 17 00:00:00 2001 From: David Jennes Date: Wed, 17 May 2017 11:23:33 +0200 Subject: [PATCH 11/12] Changelog entry --- CHANGELOG.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfdb3f8..28af695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,11 +13,14 @@ ### Breaking Changes * Templates are now organized in subdirectories for each command. - [@djbe](https://github.com/djbe) + [David Jennes](https://github.com/djbe) [#13](https://github.com/SwiftGen/templates/issues/13) * Update templates to use the Stencil built-in `join` filter instead of our own. - [@djbe](https://github.com/djbe) + [David Jennes](https://github.com/djbe) [#22](https://github.com/SwiftGen/templates/issues/22) +* Many deprecated templates have been removed, and others have been renamed to reflect new behaviours. We've prepared a migration guide which you can find here: [Documentation/MigrationGuide](https://github.com/SwiftGen/templates/blob/master/Documentation/MigrationGuide.md). + [David Jennes](https://github.com/djbe) + [#47](https://github.com/SwiftGen/templates/issues/47) ### New Features @@ -73,7 +76,7 @@ _The templates tagged with this version are the ones embedded in SwiftGen 4.2._ * Initial tagging of templates as part of being split in their own repository. * Templates are now linted and unit-tested, to ensure the code generated compiles properly. - [@djbe](https://github.com/djbe) + [David Jennes](https://github.com/djbe) [#5](https://github.com/SwiftGen/templates/issues/5) [#6](https://github.com/SwiftGen/templates/issues/6) [#15](https://github.com/SwiftGen/templates/pull/15) @@ -82,11 +85,11 @@ _The templates tagged with this version are the ones embedded in SwiftGen 4.2._ ### Bug Fixes * Use `escapeReservedKeywords` in all templates — to ensure compilation even for scenes named with a reserved keyword. - [@djbe](https://github.com/djbe) + [David Jennes](https://github.com/djbe) [#3](https://github.com/SwiftGen/templates/issues/3) [#14](https://github.com/SwiftGen/templates/pull/14) * Storyboards templates don't `import` your app module anymore, removing that annoying warning. - [@djbe](https://github.com/djbe) + [David Jennes](https://github.com/djbe) [#19](https://github.com/SwiftGen/templates/pull/19) * It works by checking the environment variable `PRODUCT_MODULE_NAME`, which is automatically injected by Xcode if you run `swiftgen` as part of a Script Build Phase in your Xcode project. * If you don't use `swiftgen` in a Script Build Phase of your Xcode project but manually in the terminal, you can instead use `swiftgen storyboards --param module=YourAppModuleName …` when invoking SwiftGen to inject it manually instead. @@ -95,14 +98,14 @@ _The templates tagged with this version are the ones embedded in SwiftGen 4.2._ * Use an explicit bundle parameter to support frameworks for all templates. [@NachoSoto](https://github.com/NachoSoto) - [@djbe](https://github.com/djbe) + [David Jennes](https://github.com/djbe) [SwiftGen/SwiftGen#255](https://github.com/SwiftGen/SwiftGen/pull/255) [#17](https://github.com/SwiftGen/templates/pull/17) * Use `enum` instead of `struct` for namespacing in all templates. - [@djbe](https://github.com/djbe) + [David Jennes](https://github.com/djbe) [#7](https://github.com/SwiftGen/templates/issues/7) * Reworked templates to get rid of deprecated Stencil variables. - [@djbe](https://github.com/djbe) + [David Jennes](https://github.com/djbe) [#8](https://github.com/SwiftGen/templates/issues/8) [#9](https://github.com/SwiftGen/templates/issues/9) From dfcae97483ef03cbc902246532c689d8a3c5b9c1 Mon Sep 17 00:00:00 2001 From: David Jennes Date: Wed, 17 May 2017 13:29:01 +0200 Subject: [PATCH 12/12] rename macOS doc files --- Documentation/storyboards/{osx-swift2.md => macOS-swift2.md} | 0 Documentation/storyboards/{osx-swift3.md => macOS-swift3.md} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Documentation/storyboards/{osx-swift2.md => macOS-swift2.md} (100%) rename Documentation/storyboards/{osx-swift3.md => macOS-swift3.md} (100%) diff --git a/Documentation/storyboards/osx-swift2.md b/Documentation/storyboards/macOS-swift2.md similarity index 100% rename from Documentation/storyboards/osx-swift2.md rename to Documentation/storyboards/macOS-swift2.md diff --git a/Documentation/storyboards/osx-swift3.md b/Documentation/storyboards/macOS-swift3.md similarity index 100% rename from Documentation/storyboards/osx-swift3.md rename to Documentation/storyboards/macOS-swift3.md